gSoap shared data types between interfaces
Asked Answered
B

2

13

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?

Bonn answered 15/9, 2012 at 1:11 Comment(2)
Not much of a solution, but my problem is fixed if i only declare a header file for the two interfaces and perform only one soapcpp2.exe command on the single interface file...Bonn
I asked a somewhat similar question (#16604743) but regarding XSD generated code.Drone
A
1

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.

Aliquant answered 10/11, 2013 at 11:38 Comment(0)
R
1

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.

Rhinitis answered 21/11, 2016 at 23:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.