我有一个WSDL文件,需要从中生成c++ web服务代码。我使用的工具链是gSOAP。
问题在于,生成的服务器类为每个操作拥有一个函数,参数为
WSDL文件:
问题在于,生成的服务器类为每个操作拥有一个函数,参数为
char*
,而不是像ns2__something
结构体。我该如何强制gSOAP生成XML/C或XML/C++绑定(根据我对gSOAP文档的理解,它应该这样做[?])。WSDL文件:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="swus"
targetNamespace="swus.wsdl"
xmlns:tns="swus.wsdl"
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:ns="urn:swus"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="urn:swus"
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:ns="urn:swus"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<element name="addRequestElement">
<complexType>
<sequence>
<element name="a" type="xsd:double"></xsd:element>
<element name="b" type="xsd:double"></xsd:element>
</sequence>
</complexType>
</element>
<element name="addResponseElement">
<complexType>
<sequence>
<element name="result" type="xsd:double"></xsd:element>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="addRequest">
<part name="parameters" element="addRequestElement"/>
</message>
<message name="addResponse">
<part name="result" element="addResponseElement"/>
</message>
<portType name="calcPortType">
<operation name="add">
<input message="tns:addRequest"/>
<output message="tns:addResponse"/>
</operation>
</portType>
<binding name="swus" type="tns:calcPortType">
<SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="add">
<SOAP:operation style="document" soapAction=""/>
<input>
<SOAP:body use="literal" namespace="urn:swus" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="literal" namespace="urn:swus" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="swus">
<port name="swus" binding="tns:swus">
<SOAP:address location=""/>
</port>
</service>
</definitions>
wsdl2h -c++11 -g -a -w -y -oSWUS.h ../docs/service.wsdl
soapcpp2 -2 -S -a -A -t -c++11 -b -i ./SWUS.h
生成的代码片段:
class SOAP_CMAC swusService : public soap {
public:
/* blah blah blah... */
/// Web service operation 'add' (returns SOAP_OK or error code)
virtual int add(char *wsdl__addRequestElement, // =====>> Why?
char *wsdl__addResponseElement // =====>> Why?
) SOAP_PURE_VIRTUAL;
};