Requires Free Membership to View
There are five JAXM interaction categories:
1) Asynchronous Inquiry - This interaction requires a client to transmit a request message, but does not require the client to block for a response. The client can inquire later for the response, as it wishes.
2) Asynchronous Update with Acknowledgement - This interaction requires a client to transmit a request message, but does not require the client to block for a response. The client can inquire later for an acknowledgement that the message was received.
3) Synchronous Update - This interaction requires a client to transmit a request message and block until an acknowledgement is received.
4) Synchronous Inquiry - This interaction requires a client to transmit a request message and block until a response is received.
5) Fire and Forget - This interaction requires a client to transmit a request message, but no response is expected to be returned at all.
Within JAXM, request-response handlers and acknowledgement handlers are defined by a couple of interfaces, javax.xml.messaging.OnewayListener and javax.xml.messaging.ReqRespListener. Both interfaces declare some form of a method called "onMessage". The onMessage method takes a SOAPMessage object in both interfaces, but the return types differ. The JAXMServlet will invoke the onMessage method from its doPost() method passing to it a SOAPMessage object.
A servlet, working within JAXM, should extend JAXMServlet and also implement either the javax.xml.messaging.OnewayListener interface or the javax.xml.messaging.ReqRespListener interface. An illustration of this is as follows:
public class MyServlet extends JAXMServlet
implements ReqRespListener
{
private SOAPMessage createSOAPResponse(SOAPMessage message)
{
SOAPMessage msg = msgFactory.createMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
env.getBody()
.addChildElement(env.createName("TheResponse"))
.addTextNode("This is the response");
}
public SOAPMessage onMessage(SOAPMessage message)
{
// do message handling here
return createSOAPResponse(message);
}
} This was first published in April 2003

Join the conversationComment
Share
Comments
Results
Contribute to the conversation