我正在尝试使用gSOAP和C ++来传递一个简单结构的std :: list,使用soapstd2编译器生成我试图作为Web服务提供的遗留应用程序的相关WSDL。
下面是我在旧版C ++应用程序中定义的gSOAP标头:
//gsoap ns service name: Arpa service described at http://localhost:5801/ArpaService
//gsoap ns service protocol: SOAP
//gsoap ns service namespace: http://localhost:5801/arpa.wsdl
//gsoap ns service location: http://localhost:5801/arpaserver.cgi
#import "stl.h"
class ns__arpaTarget
{
public:
int nTgtNo;
std::string name;
double dRange;
double dBearing;
ns__arpaTarget();
~ns__arpaTarget();
};
class ns__arpaList
{
public:
std::list <ns__arpaTarget> arpa_lst;
};
//gsoap ns service method:
int ns__getArpaList( ns__arpaList* lst );
我在Visual Studio 2008中编译它,使用以下预构建事件来生成WSDL:
W:\gSOAP\gsoap-2.8\gsoap\bin\win32\soapcpp2 -I W:\gSOAP\gsoap-2.8\gsoap\import -t W:\gSOAP\gsoap-2.8\gsoap\WS\typemap.dat -j -s gSOAPArpaWebService.h
这在服务器端都很好(我有一个构建和运行的函数的实现,并提供了我的简单结构的列表) - 它还生成了如下所示的WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Arpa"
targetNamespace="http://localhost:5801/arpa.wsdl"
xmlns:tns="http://localhost:5801/arpa.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="http://localhost:5801/arpa.wsdl"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:HTTP="http://schemas.xmlsoap.org/wsdl/http/"
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="http://localhost:5801/arpa.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="http://localhost:5801/arpa.wsdl"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="arpaTarget"><!-- ns__arpaTarget -->
<sequence>
<element name="nTgtNo" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__arpaTarget::nTgtNo -->
<element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/><!-- ns__arpaTarget::name -->
<element name="dRange" type="xsd:double" minOccurs="1" maxOccurs="1"/><!-- ns__arpaTarget::dRange -->
<element name="dBearing" type="xsd:double" minOccurs="1" maxOccurs="1"/><!-- ns__arpaTarget::dBearing -->
</sequence>
</complexType>
<!-- operation request element -->
<element name="getArpaList">
<complexType>
<sequence>
</sequence>
</complexType>
</element>
<!-- operation response element -->
<element name="arpaList">
<complexType>
<sequence>
<element name="arpa-lst" type="ns:arpaTarget" minOccurs="0" maxOccurs="unbounded"/><!-- ns__arpaList::arpa_lst -->
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getArpaList">
<part name="Body" element="ns:getArpaList"/><!-- ns__getArpaList::ns__getArpaList -->
</message>
<message name="arpaList">
<part name="Body" element="ns:arpaList"/><!-- ns__getArpaList::lst -->
</message>
<portType name="ArpaPortType">
<operation name="getArpaList">
<documentation>Service definition of function ns__getArpaList</documentation>
<input message="tns:getArpaList"/>
<output message="tns:arpaList"/>
</operation>
</portType>
<binding name="Arpa" type="tns:ArpaPortType">
<SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getArpaList">
<SOAP:operation soapAction=""/>
<input>
<SOAP:body parts="Body" use="literal"/>
</input>
<output>
<SOAP:body parts="Body" use="literal"/>
</output>
</operation>
</binding>
<service name="Arpa">
<documentation>service described at http://localhost:5801/ArpaService</documentation>
<port name="Arpa" binding="tns:Arpa">
<SOAP:address location="http://localhost:5801/arpaserver.cgi"/>
</port>
</service>
</definitions>
在客户端我引用生成的gSOAP WSDL并通过ASP.NET Web应用程序成功导入服务 - 但是当我尝试使用导入服务的服务功能来检索ns__arpaTarget列表时,服务类型只提供我不理解或不知道如何使用的以下功能标志(也许这是我的问题?):
Radar_Services_Web_Client.ArpaSrv.arpaTarget[] ArpaPortTypeClient.getArpaList( Radar_Services_Web_Client.ArpaSrv.getArpaList getArpaList1 )
注意:我在没有列表的情况下尝试了这个,并且我能够从服务中成功地将单个结构输出到客户端调用中。我还尝试了一个指向ns__arpaTarget的指针列表 - 因为gSOAP文档告诉我这是一种更安全的方法,但同样的问题也出现了(即我在客户端使用同样的奇怪签名)。
非常感谢任何帮助。 非常感谢,加里。