Tuesday, June 06, 2006

<any> Element can be mapped in a Web Service

Recently I was reading ecco's blog on Web Services and XML Documents and although he is correct saying don't use org.w3c.dom.Element in your method signature I realised that I'm often asked how to deal with just this scenario. What happens is that the infamous <any> is generated into your WSDL types and you need to be able to map that to the correct XSD. But help is at hand if you are using JDeveloper. Here are the simple steps to map Element to your XSD of choice - and you can do this pre or post generation using the Web Services Editor.

Take a really simple class as an example:

An extract of the WSDL generated for this class looks like:

But if you have the XSD that actually corresponds to your Element (and changing the Java method signature is not an option):

Then you can use the Web Services Editor to add a custom mapping between Element and blahType

You'll need a dummy serializer (even though Element is already serializable), here is a simple example:

And that's it, now your generated WSDL looks like this:

No ugly <any> in sight!


Cesare said...

Hi Susan,

I have tried to create my serilizer class but my Jdeveloper is not recognizing the Oracle.webservices.databinding.SOAPElement;

I am working with a Jdeveloper


Susan said...


Can you send me more detail on your service and serializer?


sanjay said...

Hi Susan,

Thanks for the info, but here i got a doubt, when we use a wizard during registering the web service on the jdeveloper. at that instance it will ask for the custom mappings( assuming its a new project and we did not create a java class), so under that scenario how do we map the xsd with the VO Objects

Thanks and Warm