1 package test.wsdl.jaxrpchandler2; 2 3 import org.w3c.dom.Node ; 4 5 import javax.xml.namespace.QName ; 6 import javax.xml.rpc.handler.Handler ; 7 import javax.xml.rpc.handler.HandlerInfo ; 8 import javax.xml.rpc.handler.MessageContext ; 9 import javax.xml.rpc.handler.soap.SOAPMessageContext ; 10 import javax.xml.soap.SOAPMessage ; 11 12 public class EchoServiceServerHandler3 implements Handler { 13 private HandlerInfo info; 14 15 public void init(HandlerInfo handlerInfo) { 16 info = handlerInfo; 17 } 18 19 public void destroy() { 20 } 21 22 public QName [] getHeaders() { 23 return info.getHeaders(); 24 } 25 26 public boolean handleRequest(MessageContext mc) { 27 try { 28 SOAPMessage msg = ((SOAPMessageContext ) mc).getMessage(); 29 Node child = msg.getSOAPPart().getEnvelope().getBody() 30 .getFirstChild() 31 .getFirstChild() 32 .getFirstChild(); 33 String name = child.getNodeValue(); 34 if (name != null && name.equals("Joe")) { 35 child.setNodeValue("Sam"); 36 } 37 return true; 38 } catch (Exception ex) { 39 ex.printStackTrace(); 40 return false; 41 } 42 } 43 44 public boolean handleResponse(MessageContext mc) { 45 return true; 46 } 47 48 public boolean handleFault(MessageContext mc) { 49 return true; 50 } 51 } 52 | Popular Tags |