1 22 package org.jboss.test.webservice.handlerflow; 23 24 import java.io.ByteArrayInputStream ; 25 26 import javax.xml.rpc.handler.MessageContext ; 27 import javax.xml.rpc.handler.soap.SOAPMessageContext ; 28 import javax.xml.soap.MessageFactory ; 29 import javax.xml.soap.SOAPBody ; 30 import javax.xml.soap.SOAPElement ; 31 import javax.xml.soap.SOAPMessage ; 32 33 34 35 public class ServerHandler2 extends HandlerBase 36 { 37 public boolean handleRequest(MessageContext msgContext) 38 { 39 boolean retflag = super.handleRequest(msgContext); 40 41 try 42 { 43 SOAPMessageContext soapContext = (SOAPMessageContext )msgContext; 44 SOAPMessage soapMessage = soapContext.getMessage(); 45 SOAPBody soapBody = soapMessage.getSOAPBody(); 46 SOAPElement soapElement = (SOAPElement )soapBody.getChildElements().next(); 47 soapElement = (SOAPElement )soapElement.getChildElements().next(); 48 String value = soapElement.getValue(); 49 50 61 if ("ServerReturn".equals(value)) 62 { 63 String resMsg = 64 "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + 65 " <env:Header/>" + 66 " <env:Body>" + 67 " <ns1:sayHelloResponse xmlns:ns1='http://test.jboss.org/webservice/handlerflow'>" + 68 " <result>Return in ServerHandler2</result>" + 69 " </ns1:sayHelloResponse>" + 70 " </env:Body>" + 71 "</env:Envelope>"; 72 73 MessageFactory factory = MessageFactory.newInstance(); 74 soapMessage = factory.createMessage(null, new ByteArrayInputStream (resMsg.getBytes())); 75 soapContext.setMessage(soapMessage); 76 77 return false; 78 } 79 } 80 catch (Exception ex) 81 { 82 throw new IllegalStateException ("Cannot handle request::" + ex.getMessage()); 83 } 84 return retflag; 85 } 86 } 87 | Popular Tags |