我正在尝试实现两个 Windows 服务,每个实现都是自己的 gSoap 接口,并且都是每个接口的客户端和服务器。所以我的问题是我在两个接口(带成员的类)中使用相同的数据类型,并使用将创建两个不同命名空间的 soapcpp2.exe -q 选项生成 c++ 代码,这很好,它可以工作,但问题是由于命名空间分离,两个接口中应该相等的数据类型现在不同,但是如果我删除命名空间,我将发生冲突,因为共享数据类型在两个接口中具有相同的名称。
“问题:
interface 1:
---
>class xsd__Address
{
char *email;
char *url;
};
>int ns1__getAddress(xsd__Address& ret);
---
interface 2:
---
>class xsd__Address
{
char *email;
char *url;
};
>int ns2__setAddress(xsd__Address& ret);
---
在每个头文件的定义之后,我用 sopcpp2.exe 编译它,例如:
soapcpp2.exe -qintf1 -n xxxx //用于接口1
soapcpp2.exe -qintf2 -n xxxx //用于接口2
所以当在我的项目中同时使用两个接口(接口 1 和接口 2)时,当我需要这样的东西时:
intf1::Interface1 int1;
int1.endpoint="xxx";
intf1::ns__Address address;
int1.ns1__getAddress(address);
intf2::Interface1 int2;
int2.endpoint="xxx";
int2.ns2_setAddress(address); //this don't compile like i was expecting because to the compiler they are not the same object (and it is wright...)
问题:
是否可以在两个或多个接口之间共享数据类型?是的?这是如何实现的?
如果不是,实现这一点的最佳解决方案是什么?