0

I have some C++ headers files and I want to make their content available through a webservice using gSOAP. The headers are:

Shared.h, 
A.h,
B.h; 

both A.h and B.h include (import) the Shared.h file.

I generated two separate WSDL documents: A.wsdl and B.wsdl and then I built them into a single header file (final.h) using the wsdl2h tool.

wsdl2h -x -o A.wsdl B.wsdl -tC:\gsoap-2.8.22\gsoap\typemap.dat

After that, I compiled the final.h file with soapcpp2 in order to get the C++ stubs of two proxy services (corresponding to the two WSDL mentioned above).

soapcpp2 -j -S final.h -IC:\gsoap-2.8.22\gsoap\import;C:\gsoap-2.8.22\gsoap -x -2
soapcpp2 -j -C final.h -IC:\gsoap-2.8.22\gsoap\import;C:\gsoap-2.8.22\gsoap -x -2

Two different namespaces have been used, one for each WSDL, and everything works properly, but there is a problem. Since the Shared.h file is imported by both the A.h and B.h files, the data structures coded in it appear two times in final.h file (once with the A__ prefix associated to the A namespace and once with the B__ prefix associated with the B namespace).

How can I manage to avoid this problem and get them only once?

I tried to generate a third WSDL (Shared.wsdl), but I don't know how to import it into the A.wsdl and B.wsdl. Is it possible? How should I modify the A.h and B.h files in order to do so?

Should I follow another procedure?

mpromonet
  • 11,326
  • 43
  • 62
  • 91
Knacker
  • 31
  • 1
  • 5
  • Did you look at [gsoap multiple wsdls but only one proxy class](http://stackoverflow.com/questions/13656883/gsoap-multiple-wsdls-but-only-one-proxy-class?rq=1) ? – mpromonet Jun 11 '15 at 21:28
  • Actually I did, but it's not the same issue. I managed to make the two services work using separate namespaces, what I need is to keep a single copy of the shared structures. Meanwhile I found a partial solution. It is possible to create a third namespace to assign to the Shared.h file, but when a class or struct is used in the other files, it must have the corresponding namespace prefix (if I got it right). This doesn't really solve the problem for me since changing the orginal .h files would be a problem. Anyway, thanks for the comment. – Knacker Jun 12 '15 at 08:04

0 Answers0