2016-07-14 67 views
0

如何構建Onvif GetStreamUrl消息?我曾嘗試以百萬計的可能性,這裏就是其中之一:Onvif - GetStreamUri說:「XML格式良好的違規發生」

<?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> 

官方規格是在這裏:http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl#op.GetStreamUri

有沒有人可以幫助我?

+0

如果數據中真正存在'<?xml'前面的空格,請嘗試刪除它。 – Tomalak

+0

它沒有,我也根本不在消息中使用空格。 – JochoM

+0

你發現問題是什麼?我得到了同樣的錯誤... –

回答

0

那麼如果你想自己製作信封,你可以使用下面的測試模板,併發出包含SOAP信封的http請求。

<?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> 

但使用ONVIF媒體服務,你可以得到的資料,選擇其中之一,並呼籲GetStreamUri方法與你的首選StreamSetup和所選配置文件的令牌。