gpt4 book ai didi

C++ gSOAP 文件生成

转载 作者:行者123 更新时间:2023-11-28 01:01:20 26 4
gpt4 key购买 nike

看起来 gSoap“忘记”生成很多东西了。我用过

wsdl2h.exe -o NumOpsService.h http://192.168.2.113/numops.wsdl
soapcpp2.exe -x -l -I..\..\import -C NumOpsService.h

并且两者都没有错误或警告地运行。当我将这些文件包含到我的项目中时,结果是在 soapH.h 中声明了几个函数,但缺少应位于 soapC.cpp 中的相应实现。

缺少以下功能:

SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
SOAP_FMAC3 void* SOAP_FMAC4 soap_container_id_forward(struct soap*, const char*, void*, size_t, int, int, size_t, unsigned int);
SOAP_FMAC3 void SOAP_FMAC4 soap_container_insert(struct soap*, int, int, void*, size_t, const void*, size_t);

这怎么会发生? numops.wsdl 文件有问题吗?我用来生成的文件如下所示:

<definitions name="NumOps"
targetNamespace="http://192.168.2.113/numops.wsdl"
xmlns:tns="http://192.168.2.113/numops.wsdl"
xmlns:xsd1="http://192.168.2.113/testtypes.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>
<schema targetNamespace="http://192.168.2.113/testtypes.xsd"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="AddValRequest">
<complexType>
<all>
<element name="fVal1" type="float"/>
<element name="fVal2" type="float"/>
</all>
</complexType>
</element>
<element name="AddValResponse">
<complexType>
<all>
<element name="fResult" type="float"/>
</all>
</complexType>
</element>
</schema>
</types>

<message name="AddValInput">
<part name="body" element="xsd1:AddValRequest"/>
</message>
<message name="AddValOutput">
<part name="body" element="xsd1:AddValResponse"/>
</message>

<portType name="NumOpsPortType">
<operation name="AddVal">
<input message="tns:AddValInput"/>
<output message="tns:AddValOutput"/>
</operation>
</portType>

<binding name="NumOpsSoapProxy" type="tns:NumOpsPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="AddVal">
<soap:operation soapAction="http://192.168.2.113/index.php"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>

<service name="NumOpsService">
<port name="NumOpsPort" binding="tns:NumOpsSoapProxy">
<soap:address location="http://192.168.2.113/index.php"/>
</port>
</service>

</definitions>

我是 gSOAP 的新手,不幸的是文档并没有那么多,而且互联网上似乎以前没有人遇到过这个问题,或者我看错了方向。

我已将生成的所有文件(NumOpsService.h 除外)包含到我的项目中,还添加了 stdsoap2.hstdsoap2.cpp。由于缺少函数而无法编译的源代码如下所示:

#include <stdio.h>
#include "NumOpsSoapProxy.nsmap"
#include "soapNumOpsSoapProxyProxy.h"

int main() {
NumOpsSoapProxy proxy;
_ns2__AddValRequest request;
_ns2__AddValResponse response;

request.fVal1 = 10;
request.fVal2 = 20;

if(proxy.__ns1__AddVal(&request, &response) == SOAP_OK) {
printf("%d + %d = %d\n", request.fVal1, request.fVal2, response.fResult);
}
else {
printf("Request failed.\n");
}
}

最佳答案

我的评论升级为答案:

In your soapcpp2 command line you have used -l, the letter, which generates linkable modules (experimental) when you should have used to use -1 (the number) to use SOAP 1.1 namespaces and encodings.

关于C++ gSOAP 文件生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8544054/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com