0

How can I build Onvif GetStreamUrl message? I have tried millions of possibilities, here is one of them:

   <?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Header>
    <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <UsernameToken><Username>onvif</Username>
      <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">tFvFfoo7ZZhmKv61tTBJ4agS/lM=</Password>
      <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NTcxNjg1NTQwNzg2Mzcx</Nonce>
      <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2016-07-14T14:02:27Z</Created>
      </UsernameToken>
    </Security>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <GetStreamUri xmlns="http://www.onvif.org/ver10/media/wsdl">
      <StreamSetup>
    <StreamType>RTP-Unicast</StreamType>
    <Transport>
      <TransportProtocol>UDP</TransportProtocol>
    </Transport>
      </StreamSetup>
      <ReferenceToken>profile_1_h264</ReferenceToken>
    </GetStreamUri>
  </s:Body>
</s:Envelope>

The official specification is here: http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl#op.GetStreamUri.

Is there anyone who could help me?

JochoM
  • 31
  • 5

2 Answers2

0

Well if you want to make the envelope yourself you can use the following tested template and make http request containing the SOAP envelope.

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Header>
        <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
            <wsse:UsernameToken wsu:Id="SecurityToken-906d1a56-c091-4d33-8afa-04445dd123ff" 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">
                <wsse:Username>admin</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">THHcq7prwwf/42S+A5tuorg/RMY=</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">f11vJWByh7IJBvZRi46Qeg==</wsse:Nonce>
                <wsu:Created>2016-10-19T05:42:47Z</wsu:Created>
            </wsse:UsernameToken>
        </Security>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <GetStreamUri xmlns="http://www.onvif.org/ver10/media/wsdl">
            <StreamSetup>
                <Stream xmlns="http://www.onvif.org/ver10/schema">RTP-Unicast</Stream>
                <Transport xmlns="http://www.onvif.org/ver10/schema">
                    <Protocol>UDP</Protocol>
                </Transport>
            </StreamSetup>
            <ProfileToken>2_def_profile1</ProfileToken>
        </GetStreamUri>
    </s:Body>
</s:Envelope>

But using onvif media service you can get the profiles, choose one of them and call GetStreamUri method with your preferred StreamSetup and the token of the chosen profile.

aminexplo
  • 360
  • 1
  • 13
0

You are using TransportProtocol instead of Protocol in your request body for version 10 of the ONVIF specs (https://www.onvif.org/ver10/media/wsdl/media.wsdl).

Next to that, I had the same problem regarding “XML well-formed violation occured” in the GetStreamUri call. Adding the xmlns scheme to Stream and Transport fixed the issue.

<Stream xmlns="http://www.onvif.org/ver10/schema">RTP-Unicast</Stream>
<Transport xmlns="http://www.onvif.org/ver10/schema">
    <Protocol>UDP</Protocol>
</Transport>
Verhelst
  • 1,492
  • 2
  • 22
  • 46