[Gsoap2-develop] gSOAP multi-server problems
Development toolkit for Web Services and XML data bindings for C & C++
Brought to you by:
engelen
|
From: <mic...@WE...> - 2003-12-29 12:44:53
|
Hi!
After some (successful!) simple experiments with gSOAP I started to feel =
a little more adventurous and now I've run into some problems. Please =
forgive me if this has been asked before.
I created a setup where one client needs to access multiple stand-alone =
services. The C++ source codes for both client and services are in my =
control, I can change whatever is required to make this work.
The services all have the same basic interface (same data structures for =
input and output, identical methods). They differ from each other only =
in their location (different network node and/or different port) and in =
their implementation (different heuristic algorithms for the same =
problem).
To be able to access all the services from one client, I created a gSOAP =
compiler .h file for each service and encapsulated each in a dedicated =
namespace.
Here is a somewhat stripped down example:
----8<----cut here----8<----------------------------------------
namespace Exmpl1 {
//gsoap Exmpl1 service name: Exmpl1
//gsoap Exmpl1 service documentation: Exmpl1 service
//gsoap Exmpl1 service namespace: http://urltowsdl/Exmpl1.wsdl
//gsoap Exmpl1 service port: http://server1:60001
//gsoap Exmpl1 schema namespace: urn:Ex1
#import "stlstring.h" // stlstring.h vanished in gSOAP 2.4?
typedef double xsd__double;
typedef std::string xsd__string;
typedef unsigned int xsd__positiveInteger;
// datatype used for returning results
struct Exmpl1__resultnode {
xsd__positiveInteger foo;
xsd__double bar;
}; // struct Exmpl1__resultnode
class result {
struct Exmpl1__resultnode* __ptrnode; // pointer to dynamic array
int __size 0 : 58; // number of elements in array
result();
~result();
void MethodA( double* );
void MethodB( double*, unsigned int );
}; // class result
int Exmpl1__rpc( xsd__string x, result* y ); // RPC call prototype
} // namespace Exmpl1
----------------------------------------------------------------
This approach works. However, the number of equally structured services =
is about to grow (>10) and here my problems start:
1. The struct Exmpl1::Exmpl1__resultnode is basically the same in all .h =
files I created, only the C++ namespace and the service name prefix =
changes.
Is there a way to define this data type once in a separate file and =
re-use it in all service definitions?
2. The class Exmpl1::result is identical in all .h files except for the =
C++ namespace. Especially the methods: constructor, destructor, =
MethodA() and
MethodB() have identical *implementations*.
Thus, I have to duplicate the implementation over and over again for =
each service as Exmpl1::result::MethodA(), Exmpl2::result::MethodA(), =
... which becomes painful if I have to change something. Compile time =
also is greatly affected [ ~25 minutes now :-( ]
If I try to create a base class and inherit inside the .h file I get a =
gSOAP compiler parse error for the closing brace of the class =
declaration:
class result : public class base {
...
};
Is there a way to, either re-use the 'class result' from a different =
file, as asked in problem 1, or use the C++ inheritance mechanism to =
avoid the source code duplication?
3. I really would like to store the proxy objects as generated by the =
gSOAP compiler in an common STL container (e.g. to be able to call the =
RPC method Exmpl1__rpc() from a loop).
For this it would be nice make the proxy class derived from a base class =
that can act as the data type for the container and defines the RPC =
method as virtual.
Of course, I can manually change the generated proxy header... =
shudder..., so I'd welcome any idea to help me here.
Please forgive my stupidness, I'm really somewhat new to (g)SOAP.
______________________________________________
Michael B=F6hnisch
Software Engineer
webwasher AG
Vattmannstrasse 3
33100 Paderborn / Germany
Phone: +49 52 51 / 5 00 54-434
Fax: +49 52 51 / 5 00 54-11
Mobile: +49 1 60 / 99 09 29 41
E-mail: mailto:mic...@we...
Visit us at: http://www.webwasher.com
______________________________________________
|