What is the use case for not using web services?
One example of needing to parse a SOAP message is if you are using a message driven bean to listen to a JMS queue. The text received from the queue is a String with a SOAP message. How do you go about parsing the SOAP to get at the body? Also, how do you leverage XFire's flexible binding mechanism to marshall the SOAP Body for you?
Example 1: Incoming SOAP message retrieved from a JMS queue
Here is a typical message driven bean receiving a text message:
In this example XFire is used to call a service named 'TicketReceiptMessageService' passing it the marshalled SOAP body.
The 'TicketReceiptMessageService' needs to have an operation similiar to the SOAP body element so that XFire can determine which method to call on the service. Here is our incoming SOAP message:
Here is the operation on the service which handles the incoming SOAP request:
XMLBeans was used as the binding mechanism to marshall the SOAP Body. Before using XMLBeans as the binding tool you need to use the xmlbean Ant task to generate binding classes from your XSD schema. Configuring XFire in the xfire.xml file using Spring to handle this use case:
The 'TicketReceiptMessageService' is configured in the services.xml file:
The last piece of the puzzle is the invocation code to handle a SOAP request and pass it to an XFire Channel to do the rest:
