[英]gSoap with multiple WSDLs with same operations
My client needs to be able to communication with both old and new server protocols (same endpoint), and because of that, I need to load 2 WSDL's with identical operations, but different namespaces (XML wise) 我的客户端需要能够与旧服务器协议和新服务器协议(相同的端点)进行通信,因此,我需要以相同的操作但使用不同的名称空间(XML方式)加载2个WSDL。
for instance: 例如:
<operation name="getServerTime">
<input message="uc:GetServerTimeRequest"/>
<output message="uc:GetServerTimeResponse"/>
</operation>
the wsdl2h seems to handle this fine. wsdl2h似乎处理得很好。 I run the command:
我运行命令:
wsdl2h -p -o gSoap.h service2013.wsdl service2015.wsdl
and in gSoap.h I see it successfully parsed both operations well; 在gSoap.h中,我看到它成功解析了两个操作;
int __ns2__getServerTime(
_common_2012_msgs__GetServerTimeRequest* common_2012_msgs__GetServerTimeRequest, ///< Input parameter
_common_2012_msgs__GetServerTimeResponse* common_2012_msgs__GetServerTimeResponse ///< Output parameter
);
int __ns7__getServerTime(
_common_2015_msgs__GetServerTimeRequest* common_2015_msgs__GetServerTimeRequest, ///< Input parameter
_common_2015_msgs__GetServerTimeResponse* common_2015_msgs__GetServerTimeResponse ///< Output parameter
);
but the problem is afterwards, when I generate the proxy using soapcpp2: 但是问题出在后来,当我使用soapcpp2生成代理时:
soapcpp2 -jLCx -I$(gsoap_pkg)/share/import/ gSoap.h
the result in my generated proxy (soapCommonServiceSoapBindingProxy.h) only has 1 of the operations: 我生成的代理(soapCommonServiceSoapBindingProxy.h)中的结果只有以下一项操作:
/// Web service operation 'getServerTime' (returns error code or SOAP_OK)
virtual int getServerTime(_common_2015_msgs__GetServerTimeRequest *common_2015_msgs__GetServerTimeRequest, _common_2015_msgs__GetServerTimeResponse *common_2015_msgs__GetServerTimeResponse) { return this->getServerTime(NULL, NULL, common_2015_msgs__GetServerTimeRequest, common_2015_msgs__GetServerTimeResponse); }
virtual int getServerTime(const char *endpoint, const char *soap_action, _common_2015_msgs__GetServerTimeRequest *common_2015_msgs__GetServerTimeRequest, _common_2015_msgs__GetServerTimeResponse *common_2015_msgs__GetServerTimeResponse);
I should also mention that before this, I tried to generate 2 seperate proxies but ran into endless linking issues due to ambiguous definitions of different structs (SOAP_ENV__FAULT and such). 我还应该提到,在此之前,我尝试生成2个单独的代理,但由于对不同结构(SOAP_ENV__FAULT等)的定义不明确,因此遇到了无尽的链接问题。 I tried to solve by manually namespacing stdsoap2.cpp and stdsoap2.h but different errors kept pouring in.
我试图通过手动命名间隔stdsoap2.cpp和stdsoap2.h来解决,但是不断出现不同的错误。
How do I successfully generate a proxy that supports both versions ? 如何成功生成同时支持两个版本的代理?
A) You can use -qname with soapccp2, so that two services generate different soap files and namespaces. A)可以将-qname与soapccp2一起使用,以便两个服务生成不同的soap文件和名称空间。
for eg 例如
soapcpp2 -j -n -C -w -qs2013 -I$(INC) service2013.wsdl
soapcpp2 -j -n -C -w -qs2015 -I$(INC) service2015.wsdl
You can refer to gSoap documentation for more details gSOAP Code Namespace 您可以参考gSoap文档以了解更多详细信息。gSOAP代码命名空间
B) For resolving namespace related linker issues, add the following code into a file (for eg namespaces.cpp), add to your project and compile. B)为了解决与名称空间相关的链接器问题,请将以下代码添加到文件中(例如namespaces.cpp),添加到您的项目中并进行编译。
#include <stdsoap2.h>
extern "C" {
SOAP_NMAC struct Namespace namespaces[] = { { NULL, NULL} };
}
C) For resolving linking issues related serialization and de-serialization functions, create an empty env.h file and compile it with the following command: C)为解决与序列化和反序列化功能相关的链接问题,请创建一个空的env.h文件,并使用以下命令对其进行编译:
soapcpp2 -n -CS -penv env.h
add envC.* to your project and compile 将envC。*添加到您的项目中并进行编译
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.