Building and Deploying an Intermediary


Although Axis can support the notion of a SOAP intermediary, Axis itself needs to do very little to support it. An intermediary is a SOAP processing node that does some work based on the requesting SOAP message, but is not the final destination of the message; so, it is responsible for forwarding the message to the next SOAP processing node in the message path . From an Axis configuration point of view, this is a simple matter of defining a chain that has as its pivot point a Transport Sender handler. This handler will determine the next SOAP processing node in the message path and send the SOAP message to it. In this way, the handler is acting like a SOAP client, so the same client APIs normally used in writing an Axis client application can (and should) be used in this handler in conjunction with any server-side APIs needed to process or interpret the incoming SOAP message.

The SOAP specification requires that two things must take place in a SOAP intermediary: All message headers targeted for this intermediary (for example, the actor attribute on the header pointing to a certain URI) are removed before the message is sent to the next SOAP processing node, and if any of those message headers are marked with the mustUnderstand=1 attribute, they must be understood by this SOAP node or a fault must be thrown. In order to locate all the SOAP headers targeted for this actor, a handler can use the following method on the SOAPEnvelope object:

 public Enumeration getHeadersByName(String namespace, String localPart); 

This method will return an enumeration of SOAPHeader objects. Once each header is processed, it is very important that the handler notify the Axis engine that this header has been processed by calling the setProcessed() method:

 Enumeration enum = soapEnv.getHeadersByName(http://www.skatestown.com/, "foo"); while (enum.hasMoreElements()) {   SOAPHeader header = (SOAPHeader) enum.nextElement();   // process header here   header.setProcessed(true); } 

Setting the Processed flag on this header indicates to Axis that the header has been successfully processed. The Axis engine will then use this information to determine if any headers in the message marked with a mustUnderstand=1 attribute are unprocessed, and if so throw a mustUnderstand fault.

Currently, in the alpha release of Axis, intermediary support is not complete. In particular, support is not yet included for indicating which headers should be removed before the message should be sent to the next SOAP processing node.



Building Web Services with Java. Making Sense of XML, SOAP, WSDL and UDDI
Building Web Services with Java: Making Sense of XML, SOAP, WSDL and UDDI
ISBN: B000H2MZZY
EAN: N/A
Year: 2001
Pages: 130

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net