viernes, 7 de marzo de 2014

...regarding unwrapped in SwitchYard SOAP bindings

Hi again,
I've been playing a while with SwitchYard and the SOAP binding, for Web Services kind of services, where one would do the Components with java,camel,whatever and make them accessible through a Java interface. Then one could probably promote the component service, as a composite service, and then publish it with a WSDL interface.
For that to work, you need to transform from you SOAP messages to Java beans or basic types. You have a bunch of options for which JAXB is the easiest one, for this kind of transformations, just annotate your beans, and you should be ready.

Your beans, need to be annotated with @XMLRootElement and have an ObjectFactory class that will provide for the required transformations between XML and Java and back.

These annotated beans and ObjectFactory class can be generated with wsconsume script located in the bin folder of the AS. Just run the script against your wsdl and keep the sources.

One thing that nobody may know is that for SwitchYard it is easier to work with unwrapped messages so, there is an option, when creating/configuring the SOAP binding that says "Unwrapped payload", as can be seen here:
What this means is that it will remove the wrapper part of the message, which usually translates to the operation for you.
If you have this original message:

  1. <soap:Body>  
  2.         <orders:submitOrder xmlns:orders="urn:switchyard-quickstart:bean-service:1.0">  
  3.             <order>  
  4.                 <orderId>PO-19838-XYZ</orderId>  
  5.                 <itemId>BUTTER</itemId>  
  6.                 <quantity>200</quantity>  
  7.             </order>  
  8.         </orders:submitOrder>  
  9. </soap:Body>  

The message you will need to handle in the transformation will be:

  1. <order xmlns:orders="urn:switchyard-quickstart:bean-service:1.0">  
  2.                 <orderId>PO-19838-XYZ</orderId>  
  3.                 <itemId>BUTTER</itemId>  
  4.                 <quantity>200</quantity>  
  5. </order>  


So beware of this functionality, and understand how it works.


There is a comment in the code, that reads:

if (unwrapped){ ...// peel off the operation wrapper, if present ...}

No hay comentarios: