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 public class ClientHandler2 extends HandlerBase 35 { 36 public boolean handleRequest(MessageContext msgContext) 37 { 38 boolean retflag = super.handleRequest(msgContext); 39 40 try 41 { 42 SOAPMessageContext soapContext = (SOAPMessageContext )msgContext; 43 SOAPMessage soapMessage = soapContext.getMessage(); 44 SOAPBody soapBody = soapMessage.getSOAPBody(); 45 SOAPElement soapElement = (SOAPElement )soapBody.getChildElements().next(); 46 soapElement = (SOAPElement )soapElement.getChildElements().next(); 47 String value = soapElement.getValue(); 48 49 60 if ("ClientReturn".equals(value)) 61 { 62 String resMsg = 63 "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + 64 " <env:Header/>" + 65 " <env:Body>" + 66 " <ns1:sayHelloResponse xmlns:ns1='http://test.jboss.org/webservice/handlerflow'>" + 67 " <result>Return in ClientHandler2</result>" + 68 " </ns1:sayHelloResponse>" + 69 " </env:Body>" + 70 "</env:Envelope>"; 71 72 MessageFactory factory = MessageFactory.newInstance(); 73 soapMessage = factory.createMessage(null, new ByteArrayInputStream (resMsg.getBytes())); 74 soapContext.setMessage(soapMessage); 75 76 return false; 77 } 78 } 79 catch (Exception ex) 80 { 81 throw new IllegalStateException ("Cannot handle request::" + ex.getMessage()); 82 } 83 return retflag; 84 } 85 } 86 | Popular Tags |