JAX-WS: How to input and output XML AnyType

JAX-WS works in a very simple and effective way if you have defined all objects in a XML Schema definition. But sometimes you can’t define a schema for an operation because e.g. it is a generic operation and accepts or returns dynamic XML.

Nevertheless we would like to use for this operation the same tool chain with JAX-WS which is working perfectly for other operations.

In the first step we define the interface of the operation testXMLCall in the WSDL (better the XSD referenced by the WSDL).

From this WSDL we generate the interface PortType of the webservice. The implementation of the interface needs an operation of this definition:

We make an implementation:

We make an implementation of the method getPrintString for a readable output of the XML.

And finally the method doSomething processing the xml element and returning an XmlObject needs to be implemented.

Bernhard Mähr @ OPITZ-CONSULTING published at http://thecattlecrew.wordpress.com/

Leave a Reply