Onvif - Invalid SOAP message or SOAP version mismatch

▼魔方 西西 提交于 2019-12-08 14:53:54

问题


I have really been confused with Onvif Authentication.

I have failed to execute onvif commands both on AXIS ans SONY cameras.

Here is the code generating a request:

procedure RebootDevice(dev: Device; Username, Password: string);
var
  sdt: SystemDateTime;
  Created: string;
  Nonce: string;
  Nonce64: string;
  Password64: string;
  Header: Security;
begin
  sdt := dev.GetSystemDateAndTime;
  Created := SystemDateTimeToStr(sdt.UTCDateTime); // yyyy-MM-ddTHH.mm.ss.000Z
  Nonce := '1234';
  Nonce64 := Base64Encode(Nonce);
  Password64 := Base64Encode(HashSHA1(Nonce+Created+Password));
  Header.UsernameToken.Username := Username;
  Header.UsernameToken.Password.Type := 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest';
  Header.UsernameToken.Password.Text := Password64;
  Header.UsernameToken.Nonce.EncodingType := 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary';
  Header.UsernameToken.Nonce.Text := Nonce64;
  Header.UsernameToken.Created := Created;
  SetHeader(Header)
  dev.SystemReboot;  // <---- Error in here
end;

Generated SOAP XML:

<?xml version="1.0"?>
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Header 
        SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:NS1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <NS1:Security
            SOAP-ENV:mustUnderstand="1">
            <NS1:UsernameToken>
                <Username>
                    admin
                </Username>
                <NS1:Password 
                    Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">
                   +sWiewkgfkjFqzW2O5cuGJr9SiE=
                </NS1:Password>
                <NS1:Nonce 
                    EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
                    MTIzNA==
                </NS1:Nonce>
                <Created>
                    2004-01-03T08:20:09.000Z
                </Created>
            </NS1:UsernameToken>
        </NS1:Security>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body 
        xmlns:NS2="http://www.onvif.org/ver10/device/wsdl"
        SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
       <NS2:SystemReboot/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And this is the response:

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

Could you please tell ma what is going wrong.

Thank you


回答1:


Troubleshooting hints:

  • First, try to access the service with a tool like SoapUI and verify it sends the expected response
  • Compare the request (header and body) of SoapUI and Delphi

Or

  • capture the HTTP traffic with Fiddler or Wireshark and compare the Delphi / OnvifDM requests


来源:https://stackoverflow.com/questions/11646482/onvif-invalid-soap-message-or-soap-version-mismatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!