The onMessage method needs to disassemble the SOAP message that is passed to it by the servlet and process its contents in an appropriate manner. If there are problems in the processing of the message, the service needs to create a SOAP fault object and send it back to the client as described in Handling SOAP Faults.
Processing the SOAP message may involve working with the headers as well as locating the body elements and dealing with their contents. The following code sample shows how you might disassemble a SOAP message in the body of your onMessage method. Basically, you need to use a Document Object Model (DOM) API to parse through the SOAP message.
See http://xml.coverpages.org/dom.html for more information about the DOM API.
{http://xml.coverpages.org/dom.html SOAPEnvelope env = reply.getSOAPPart().getEnvelope(); SOAPBody sb = env.getBody(); // create Name object for XElement that we are searching for Name ElName = env.createName("XElement"); //Get child elements with the name XElement Iterator it = sb.getChildElements(ElName); //Get the first matched child element. //We know there is only one. SOAPBodyElement sbe = (SOAPBodyElement) it.next(); //Get the value for XElement MyValue = sbe.getValue(); } |