| 1 |
package test.wsdl.jaxrpchandler2; |
| 2 |
|
| 3 |
import java.io.*; |
| 4 |
import java.io.InputStream; |
| 5 |
import java.util.*; |
| 6 |
import java.util.Iterator; |
| 7 |
|
| 8 |
import javax.xml.namespace.QName; |
| 9 |
import javax.xml.rpc.handler.*; |
| 10 |
import javax.xml.rpc.handler.soap.SOAPMessageContext; |
| 11 |
import javax.xml.soap.*; |
| 12 |
import javax.xml.soap.SOAPMessage; |
| 13 |
import javax.xml.transform.stream.*; |
| 14 |
|
| 15 |
public class EchoServiceServerHandler implements Handler { |
| 16 |
|
| 17 |
public boolean handleRequest(MessageContext messageContext) { |
| 18 |
|
| 19 |
try { |
| 20 |
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) messageContext; |
| 21 |
|
| 22 |
SOAPMessage soapMsg = soapMsgCtx.getMessage(); |
| 23 |
SOAPPart soapPart = soapMsg.getSOAPPart(); |
| 24 |
SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); |
| 25 |
soapEnvelope.getBody().detachNode(); |
| 26 |
SOAPBody soapBody = soapEnvelope.addBody(); |
| 27 |
SOAPBodyElement echoElement = soapBody.addBodyElement(soapEnvelope.createName("echo", "ns1", "http://soapinterop.org/")); |
| 28 |
SOAPElement argElement = echoElement.addChildElement("arg0"); |
| 29 |
argElement = argElement.addAttribute(soapEnvelope.createName("type", "xsi", "http://www.w3.org/2001/XMLSchema-instance"), "xsd:string"); |
| 30 |
argElement.addTextNode("my echo string"); |
| 31 |
|
| 32 |
} catch (Exception e) { |
| 33 |
e.printStackTrace(); |
| 34 |
} |
| 35 |
|
| 36 |
return true; |
| 37 |
} |
| 38 |
|
| 39 |
public boolean handleResponse(MessageContext messageContext) { |
| 40 |
return true; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
public boolean handleFault(MessageContext messageContext) { |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
public void init(HandlerInfo arg0) { |
| 49 |
} |
| 50 |
|
| 51 |
public void destroy() { |
| 52 |
} |
| 53 |
|
| 54 |
public QName[] getHeaders() { |
| 55 |
return null; |
| 56 |
} |
| 57 |
|
| 58 |
} |