Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gSoap shared data types between interfaces

Tags:

c++

client

gsoap

I'm trying to implement two windows services that each one implements is own gSoap interface, and both are clients and servers of each interface. So my problem is that i use the same data type in both interfaces (class with members) and generate the c++ code with the soapcpp2.exe -q option that will create two different namespaces, this is fine and it works, but the problem is that the data type that should be equal in both interfaces are now different due to the namespace separation, but if i remove the namespaces i will have conflicts because the shared data type have the same name in both interfaces.

«Problem:

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);

---

after the definition of each header i compile it with soapcpp2.exe something like:

soapcpp2.exe -qintf1 -n xxxx //for interface 1

soapcpp2.exe -qintf2 -n xxxx //for interface 2

so when in my project that uses both interfaces (interface 1 and interface 2) when i need something like this:

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...)

Questions:

Is possible to have shared data types between two or more interfaces? Yes? how this is accomplished?

If not what is the best solution to implement this?

like image 941
Nuno Avatar asked Sep 15 '12 01:09

Nuno


2 Answers

Last I worked with gSOAP (2008?), it didn't offer any flexibility with shared structures. I can't comment if it's possible today in 2013.

However, as a quick workaround, you can try merging 2 WSDLs into one (e.g. as a part of the build), and then generating a unified SOAP stack.

like image 177
Alex B Avatar answered Nov 04 '22 10:11

Alex B


You already have two possible solutions: 1. Use namespaces and deal somehow with the formally different data types. 2. Merge WSDL files and run gSOAP compiler only once against the result.

I spent several weeks in 2015 trying to find a better solution, but there was not any.

like image 26
Alan Milton Avatar answered Nov 04 '22 11:11

Alan Milton