无效的SOAP消息或SOAP版本不匹配

时间:2015-07-27 18:49:04

标签: soap

我使用SOA Client Firefox插件向一些ONVIF摄像机发送了一个SOAP请求。您将在下面看到“GetServices”的请求。请求。它适用于一台摄像机,但对于另一台(AXIS摄像机),我收到错误:'无效的SOAP消息或SOAP版本不匹配'。

还有其他问题。但是没有一个答案对我来说很清楚。一个提到改用肥皂版本1.2(我该怎么做?)。这个似乎通过一个简短的评论来解决:Onvif - Invalid SOAP message or SOAP version mismatch 如果有人认为这与我的案件有关,请你扩展它。

URL = http://10.253.253.2/onvif/device_service
Method = POST

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
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:ns0="http://www.onvif.org/ver10/device/wsdl" 
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
    <wsse:Security mustUnderstand="true">
        <wsse:UsernameToken>
            <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">sLOOZG8o+369zaBclGwn4+tjOac=</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NWQyMzVjNGNhYmIxMTQ1ZjEzZWVlYzcyZDkzZjcwODI=</wsse:Nonce>
            <wsu:Created>2015-07-27T15:47:31.178534Z</wsu:Created>
        </wsse:UsernameToken>
    </wsse:Security>
</SOAP-ENV:Header>
<ns1:Body>
    <ns0:GetServices>
        <ns0:IncludeCapability>false</ns0:IncludeCapability>
    </ns0:GetServices>
</ns1:Body>
</SOAP-ENV:Envelope>

错误回复......

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 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:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:aa="http://www.axis.com/vapix/ws/action1" xmlns:aev="http://www.axis.com/vapix/ws/event1" xmlns:ali1="http://www.axis.com/vapix/ws/light/CommonBinding" xmlns:ali2="http://www.axis.com/vapix/ws/light/IntensityBinding" xmlns:ali3="http://www.axis.com/vapix/ws/light/AngleOfIlluminationBinding" xmlns:ali4="http://www.axis.com/vapix/ws/light/DayNightSynchronizeBinding" xmlns:ali="http://www.axis.com/vapix/ws/light" xmlns:tan1="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:tan2="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev1="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:tev2="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tev4="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
    <SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Code>
        <SOAP-ENV:Value>env:VersionMismatch</SOAP-ENV:Value>
    </SOAP-ENV:Code>
    <SOAP-ENV:Reason>
        <SOAP-ENV:Text xml:lang="en">SOAP version mismatch</SOAP-ENV:Text>
    </SOAP-ENV:Reason>
    <SOAP-ENV:Detail>
        <SOAP-ENV:Text>Invalid SOAP message or SOAP version mismatch</SOAP-ENV:Text>
    </SOAP-ENV:Detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

更新

我发现要更改为SOAP v1.2,您需要使用 http://www.w3.org/2003/05/soap-envelope代替http://schemas.xmlsoap.org/soap/envelop。 我尝试过(上面的代码中有两个替换)但是它在任何一个相机中都不起作用。我看不出我做错了什么。

2 个答案:

答案 0 :(得分:1)

好的想通了。轴摄像头需要SOAP v1.2。并且版本之间的差异是:xmlns的名称空间url:SOAP-ENV; http标题中的内容类型和操作。

ONVIF使用SOAP v1.1 ...

    url = http://10.253.253.159/onvif/device_service

    Method = POST

    http header = Content-Type: text/xml; charset=utf-8; action="http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime";

    <SOAP-ENV:Envelope 
                xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                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:wsdl="http://www.onvif.org/ver10/device/wsdl"
                xmlns:sch="http://www.onvif.org/ver10/schema"
         >
        <SOAP-ENV:Header>
            <wsse:Security mustUnderstand="true">
                <wsse:UsernameToken>
                    <wsse:Username>admin</wsse:Username>
                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0">admin</wsse:Password>
                    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NWQyMzVjNGNhYmIxMTQ1ZjEzZWVlYzcyZDkzZjcwODI=</wsse:Nonce>
                    <wsu:Created>2015-07-27T15:47:31.178534Z</wsu:Created>
                </wsse:UsernameToken>
            </wsse:Security>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>              
            <wsdl:GetSystemDateAndTime/> 
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

ONVIF使用SOAP v1.2 ...

    url = http://10.253.253.159/onvif/device_service

    Method = POST

    http header = Content-Type: application/soap+xml; charset=utf-8;  

    <SOAP-ENV:Envelope 
                xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                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:wsdl="http://www.onvif.org/ver10/device/wsdl"
                xmlns:sch="http://www.onvif.org/ver10/schema"
         >
        <SOAP-ENV:Header>
            <wsse:Security mustUnderstand="true">
                <wsse:UsernameToken>
                    <wsse:Username>admin</wsse:Username>
                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0">admin</wsse:Password>
                    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NWQyMzVjNGNhYmIxMTQ1ZjEzZWVlYzcyZDkzZjcwODI=</wsse:Nonce>
                    <wsu:Created>2015-07-27T15:47:31.178534Z</wsu:Created>
                </wsse:UsernameToken>
            </wsse:Security>                
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>              
            <wsdl:GetSystemDateAndTime/>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

答案 1 :(得分:1)

@ spiderplant0给出了正确的答案。以我为例,我有一个SoapUI项目,并且试图调用Soap 1.2端点。我在该项目中配置了WS-Security,并且在“签名”步骤(尤其是在“正文”部分)中使用了错误的名称空间“ http://schemas.xmlsoap.org/soap/envelope/”。由于这种错误配置,端点一直告诉我它“无法验证请求:安全处理失败(操作不匹配)”,这对我来说没有意义,因为WS-Security步骤的顺序正确。 / p>

我用正确的名称“ http://www.w3.org/2003/05/soap-envelope”替换了错误的名称空间,并且有效!

感谢@ spiderplant0指出这一点!