I was recently attempting to upgrade an existing .NET 1.1 application to .NET 2.0. One of the pieces that broke unexpectedly was a call to an Apache Axis 1.3 web service. I was surprised to find out that a simple update web reference inside of Visual Studio 2005 didn’t solve the problem.
Originally, the Java web service was generated using the Eclipse Web Service Tools wizard. In this specific instance, I generated the WSDL from an existing class and let the tool do the bulk of the work for me. One of the options chosen was RPC/Encoded Style. I never encountered any issues with this setting with .NET 1.1. In my research, I discovered that this setting was not recommended.
I encountered two issues with the conversion. After I initially recompiled the .NET 2.0 client and attempted to call the web service, the application threw an exception that stated “There is an error in XML document (1, 381)”, with an inner exception stated “Item has already been added. Key in dictionary:…”. When I converted the Java Web Service to use document/literal (wrapped) style this issue went away.
The second issue I discovered was a specific method was returning a complex type that .NET 2.0 was not filling the client side object. Looking at the packet coming back with Fiddler it was clear that the data was coming back from the server, but .NET was ignoring the data. I found it strange that an exception wasn’t raised or a null value wasn’t returned. Instead, a newly created class with default values was returned. I tried numerous changes but didn’t have any luck.
More searching revealed a possible clue – a namespace mismatch. I compared the generated WSDL with the data coming back and sure enough, the response namespace didn’t match the expected WSDL namespace.
Fixing this issue was easier than expected, by using the Eclipse Web Service Tools, checking “Define custom mapping for package to namespace” and mapping the response class to the default namespace. (e.g. com.example.service.foo.obj to foo.service.example.com).
The bottom line here for making your interoperability as painless as possible between .NET 2.0 and Apache Axis 1.3 is that you should use “document/literal (wrapped)” and make sure your complex types are in the same namespace as your service.