We have Axis2 POJO services that are currently consumed by a C# client and we're adding a Java client. Generating equivalent stubs is turning out to be somewhat difficult.
We generate the classes using the .NET wsdl tool which has an option to share types between multiple services.
http://mymachine/appname/services/Service1?wsdl
http://mymachine/appname/services/Service2?wsdl
...ect
For the C# client we use the wsdl tool included with Visual Studio and life is wonderful
wsdl /n:MyPackage /out:ourservice-webservice.cs /sharetypes "http://mymachine/appname/services/Service1?wsdl" "http://mymachine/appname/services/Service2?wsdl"
Now we're trying to add a Java client and I'm running into an issue using the code generated from wsdl2java
wsdl2java -uri http://mymachine/appname/services/Service1?wsdl -uw -or -o src -p MyPackage
wsdl2java -uri http://mymachine/appname/services/Service2?wsdl -uw -or -o src -p MyPackage
This seemed to work until I tried to use a call from Service1 and one from Service2 that both use the type MyTransaction.
Right now the generated stubs show it as Service1Stub.MyTransaction and Service2Stub.MyTransaction which are of course different types.
This is a problem as we have to move objects back and forth across the two services. I assume there's an easy fix I'm missing?
As you've noted, the databinding classes (MyTransaction
and so on) are being generated as inner classes of the stub classes. So each stub has its own copy of the MyTransaction
class which isn't compatible with the other one.
The wsdl2java parameter -u
will cause the databinding classes to be generated as regular classes, each in its own file. If the two MyTransaction
definitions are actually identical, then wsdl2java would generate the same class file for each of the MyTransaction
objects, and you'd be able to share MyTransaction
objects between the two services.
This page describes the wsdl2java parameters in detail.