I’m trying to learn the basics of communicating with the Milestone Open Bridge, so I’m taking the approach of sending requests to it via SOAP calls and observing the results. Here’s what I’ve tried and here are the results. The reply seems to suggest a user authorization issue, however I’m using Basic User information that is known to work as it has been used to log in via the ONVIF Device Manager.
Any suggestions are appreciated. URL, USERNAME, and PASSWORD replace actual values that were used in the code
SOAP call via python:
import requests
import xml.dom.minidom
# Set the URL for the ONVIF request
url = 'http://URL:580/onvif/Device'
# Set the headers for the ONVIF request
headers = {
'Content-Type': 'application/soap+xml;charset=utf-8',
}
# Set the SOAP message for the ONVIF request
soap_message = '''<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:d="http://www.onvif.org/ver10/device/wsdl">
<SOAP-ENV:Header>
<wsa:MessageID>urn:uuid:8f68ae06-f547-4271-9096-88f8c00572f0</wsa:MessageID>
<wsa:To>http://URL:580/onvif/Device</wsa:To>
<wsa:Action>http://www.onvif.org/ver10/device/wsdl/GetServices</wsa:Action>
<Security>
<wsse:UsernameToken>
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password>PASSWORD</wsse:Password>
</wsse:UsernameToken>
</Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<d:GetDeviceInformation/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'''
# Send the ONVIF request to the server
response = requests.post(url, headers=headers, data=soap_message)
# Parse the response XML and pretty-print it
xml_doc = xml.dom.minidom.parseString(response.content)
pretty_xml = xml_doc.toprettyxml()
print(pretty_xml)
And I received this response:
<?xml version="1.0" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:Dyn="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:Dyn2="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tse="http://www.onvif.org/ver10/search/wsdl">
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<SOAP-ENV:Code>
<SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value>
<SOAP-ENV:Subcode>
<SOAP-ENV:Value>ter:NotAuthorized</SOAP-ENV:Value>
</SOAP-ENV:Subcode>
</SOAP-ENV:Code>
<SOAP-ENV:Reason>
<SOAP-ENV:Text xml:lang="en">Sender not authorized</SOAP-ENV:Text>
</SOAP-ENV:Reason>
<SOAP-ENV:Detail>
<SOAP-ENV:Text>The action requested requires authorization and the sender is not authorized</SOAP-ENV:Text>
</SOAP-ENV:Detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>