首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过gSoap发送多维stl::vector或数组

通过gSoap发送多维stl::vector或数组
EN

Stack Overflow用户
提问于 2012-02-09 17:37:36
回答 1查看 1.4K关注 0票数 0

我已经构建了一个PHP soap函数,接收字符串数组的数组,并将其写入文件。

下面是Soap服务器的WSDL文件:

代码语言:javascript
复制
This XML file does not appear to have any style information associated with it. The        document tree is shown below.
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="ADRESSE_WEBSERVICE"     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-    enc="http://schemas.xmlsoap.org/soap/encoding/"     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="BoWS"     targetNamespace="ADRESSE_WEBSERVICE">
<types>
<xsd:schema targetNamespace="ADRESSE_WEBSERVICE"/>
</types>
<portType name="BoWSPort">
<operation name="writeArray">
<documentation>This method count and write an array</documentation>
<input message="tns:writeArrayIn"/>
<output message="tns:writeArrayOut"/>
</operation>
</portType>
<binding name="BoWSBinding" type="tns:BoWSPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="writeArray">
<soap:operation soapAction="ADRESSE_WEBSERVICE#writeArray"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="ADRESSE_WEBSERVICE"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="ADRESSE_WEBSERVICE"/>
</output>
</operation>
</binding>
<service name="BoWSService">
<port name="BoWSPort" binding="tns:BoWSBinding">
<soap:address location="ADRESSE_WEBSERVICE"/>
</port>
</service>
<message name="writeArrayIn">
<part name="array" type="soap-enc:Array"/>
</message>
<message name="writeArrayOut">
<part name="return" type="xsd:int"/>
</message>
</definitions>

当我通过soapUI测试时,该函数工作正常,如下所示:

代码语言:javascript
复制
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="ADRESSE_WEBSERVICE">
   <soapenv:Header/>
   <soapenv:Body>
      <wsdl:writeArray soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <SOAP-ENC:Array SOAP-ENC:arrayType="xsd:string[][3]">
   <SOAP-ENC:Array id="array-1" SOAP-ENC:arrayType="xsd:string[4]">
    <item>26</item>
    <item>223</item>
    <item>test</item>
    <item>test3</item>
    </SOAP-ENC:Array>
   <SOAP-ENC:Array id="array-2" SOAP-ENC:arrayType="xsd:string[4]">
    <item>26</item>
    <item>750</item>
    <item>test</item>
    <item>test4</item>
    </SOAP-ENC:Array>
    <SOAP-ENC:Array id="array-3" SOAP-ENC:arrayType="xsd:string[4]">
    <item>70</item>
    <item>360</item>
    <item>tes321</item>
    <item>test23</item>
    </SOAP-ENC:Array>
</SOAP-ENC:Array>
      </wsdl:writeArray>
   </soapenv:Body>
</soapenv:Envelope>

我必须向该函数发送来自C++程序的多维数组/字符串向量。

我已经用wsdl2h生成了gSoap头和函数。

该函数的数组参数是soapStub.h文件中生成的结构:

代码语言:javascript
复制
struct _Struct_3
{
public:
    char **__ptr;
    int __size;
};

我的问题是,我不知道如何将这种结构用作多维数组。

我必须插入的数组在原点是一个字符串向量的向量:

代码语言:javascript
复制
vector< vector<string> > testArray

我可以很容易地将其转换为字符串数组。

EN

回答 1

Stack Overflow用户

发布于 2012-02-11 04:45:22

这个WSDL的问题是没有数组及其元素的类型信息,只有一个对泛型"soap-enc: array“的引用。

运行wsdl2h后,在生成的.h文件中将此声明更改为:

代码语言:javascript
复制
struct _Struct_3
{
    std::string *__ptr;
    int __size[2]; // 2D array
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9208354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档