wood burning stoves 2.0*
The moose likes Web Services and the fly likes @WebService method returning a custom class containing a HashMap / JAX-WS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "@WebService method returning a custom class containing a HashMap / JAX-WS" Watch "@WebService method returning a custom class containing a HashMap / JAX-WS" New topic

@WebService method returning a custom class containing a HashMap / JAX-WS

M Streit

Joined: Jan 16, 2004
Posts: 27
I am hoping someone else has seen this issue before.

I have JAX-WS endpoint service that has a method:

The hand coded BookOrder class looks like this:

We want to be able to compile our Java Bean objects into a "shared jar" that can be used by both the Client and Service sides of the wire - this is unusual, but in this case, the project owns both ends of the wire so they want to enforce consistent use of these objects. In the case of custom java classes, this approach works fine as we have done it w/o a problem as long as none of the classes use Map types (like HashMap).

The generated version of BookOrder.java looks like this (below) - (after running wsimport pointing at the WSDL served back from the running endpoint service). Of course the generated ObjectFactory.java file is based on this "generated" version of the Java bean classes. Now the BookOrder.java in the shared jar file and this generated BookOrder.java are different in that wsimport and JAXB have created a class w/ some inner class constructs to handle the ORIGINAL HashMap defined. This is where the problem occurs because when attempting to compile the client side code, we run into issues all resulting from this DIFFERENCE in mapping.

(removed most of the generated COMMENTs to shorten this post - it's already long enough :-) )

The XML schema generated when the service endpoint was deployed (in addition to its WSDL) had the following definition for BookOrder:

Is there any way, using a custom binding file passed to wsimport to force the client-side generation process to end up with consistent classes such that the generated ObjectFactory.java can still work w/ our "shared" compiled JAR file containing our hand-coded BookOrder.java class? In other words, can we get the client-side generated BookOrder.java to match the original? I'd appreciate any suggestion or example where someone may have done this...assuming it is even possible.

In general, if we have Arrays or List types, none of this is a problem...but w/ Map types, it falls apart.

Thanks in advance.

I agree. Here's the link: http://aspose.com/file-tools
subject: @WebService method returning a custom class containing a HashMap / JAX-WS
Similar Threads
web services client is not validating parameters
Netbeans jax-ws generated sources erroring on method invocation.
jaxws and polymorfism
JAXB Problem
Generating less JAXB classes