我正在使用gsoap和onvif,几天前我遇到了错误SOAP_TYPE 这是我用wsdl2h和soapcpp2的命令:
wsdl2h -P -x -Ie:\gsoap2.8.24\gsoap -o onvif.h http://www.onvif.org/onvif/ver20/analytics/wsdl/analytics.wsdl ....
soapcpp2 -j2Cx -IE:\gsoap2.8.24\gsoap;E:\gsoap2.8.24\gsoap\import onvif.h
我只是实现了这个简单的wsdl函数来询问来自ONVIF的Analytics Service的信息 http://www.onvif.org/onvif/ver20/analytics/wsdl/analytics.wsdl#op.GetServiceCapabilities
这是简化的功能代码:
~~~~
struct soap soapdata;
soap_init(&soapdata);
RuleEngineBindingProxy onvifRuleEngine(&soapdata);
/*---------------------------------------------------------*/
_tan__GetServiceCapabilities tan__GetServiceCapabilitiesRequest;
_tan__GetServiceCapabilitiesResponse tan__GetServiceCapabilitiesResponse;
result = onvifRuleEngine.GetServiceCapabilities(analyticsEndpoint, NULL, &tan__GetServiceCapabilitiesRequest, tan__GetServiceCapabilitiesResponse);
if (result == SOAP_OK) {
cout << tan__GetServiceCapabilitiesResponse.Capabilities->AnalyticsModuleSupport << endl;
}
else cout << "Error: " << soapdata.error << endl;
~~~~
但是gsoap状态返回错误4,即
SOAP_TYPE:XML架构类型不匹配
我没有在日志文件中看到任何错误,在TEST.log中有一些PUSH不行,但我认为这不是问题,它正确发送和接收XML消息,我将其附加在下面,但该函数返回错误4
其他服务如设备和媒体I可以正常运行而无错误
为SENT.log
POST /onvif/Analytics HTTP/1.1
Host: remotedacrib.dynip.sapo.pt
User-Agent: gSOAP/2.8
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver20/analytics/wsdl/GetServiceCapabilities"
Content-Length: 1444
Connection: close
SOAPAction: "http://www.onvif.org/ver20/analytics/wsdl/GetServiceCapabilities"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" 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:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" 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:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Body><tan:GetServiceCapabilities></tan:GetServiceCapabilities></SOAP-ENV:Body></SOAP-ENV:Envelope>
RECV.log
HTTP/1.1 200 OK
Date: Tue, 01 Dec 2015 10:39:27 GMT
Server: App-webs/
Connection: close
Content-Length: 2033
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnshik="http://www.hikvision.com/2011/event/topics"><env:Body><tan:GetServiceCapabilitiesResponse><tan:Capabilities RuleSupport="TRUE" AnalyticsModuleSupport="TRUE" CellBasedSceneDescriptionSupported="FALSE"/>
</tan:GetServiceCapabilitiesResponse>
</env:Body>
</env:Envelope>
答案 0 :(得分:1)
您可以尝试在wsdl2h中使用-d选项。 这对我有帮助。 SOAP-TYPE错误是XML Schema类型不匹配错误。这个-d选项将使你的类文件能够处理xs:anytype,anyattribute ....