2017-05-20 118 views
1

我正在使用gSoap为ONVIF相机构建Web服务。 我使用ONVIF在https://www.onvif.org/profiles/specifications/提供的核心wdsl生成了头文件和源文件。gSoap故障SOAP-ENV:MustUnderstand [无子码]

然而,每次我让来自客户端的请求时,我得到下面的错误在功能soap_begin_serve(soap)

SOAP 1.2 fault SOAP-ENV:MustUnderstand[no subcode] 
"The data in element 'Security' must be understood but cannot be processed" 

是什么上述错误的手段和如何解决呢?

编辑:这就是我接收在摄像机侧:

POST/HTTP/1.1 
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime" 
Host: localhost:8090 
Content-Length: 261 
Accept-Encoding: gzip, deflate 
Connection: Close 

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>POST/HTTP/1.1 
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver10/device/wsdl/GetScopes" 
Host: localhost:8090 
Content-Length: 905 
Accept-Encoding: gzip, deflate 
Connection: Close 

<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>admin</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">WFz21zL8rch8LRoxAPzgHRMBbr0=</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">9y79ka0xD02oCIw6GAoIPwEAAAAAAA==</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-05-21T08:15:58.902Z</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetScopes xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope> 
+0

UsernameToken/Security标题存在问题。你能发布你发送给相机的SOAP消息吗? – aminexplo

+0

发布了camera.thanks收到的请求。 – thunderbird

+0

我必须为WS-Security单独配置gsoap吗? – thunderbird

回答

0

SOAP 1.2故障SOAP-ENV:mustUnderstand属性[无子码] “在元件 '安全' 的数据必须被理解,但无法处理”

这意味着你将需要启用WS-Security来验证:

  1. #import "wsse.h"添加到.h头文件(aka。服务和数据绑定“接口文件”)以供soapcpp2处理。

  2. 在源代码中
  3. ,​​

  4. 在源代码中

    ,发送具有soap_wsse_add_UsernameTokenDigest(soap, NULL, "username", "password");

  5. 请求编译编译器标志-DWITH_OPENSSL的源代码和编译应用程序代码库之前提供用户凭据以及plugin/wsseapi.c,plugin/smdevp.c,plugin/mecevp.cplugin目录位于gSOAP发行版路径中),当然还有编译stdsoap2.cstdsoap2.cpp等生成的文件;

  6. 与OpenSSL -lssl -lcrypto链接,并且如果需要压缩则可能是-lz;

  7. 使用与gSOAP的完整的WS-Security插件功能(数字签名和/或加密)时,你应该编译所有源代码与编译器选项-DWITH_OPENSSL -DWITH_DOM -DWITH_GZIP,也与您的代码编译dom.cdom.cpp在一起。

另请参阅the WS-Security plugin gSOAP。

希望这会有所帮助。