FileDocCategorySizeDatePackage
ClientHandler.javaAPI DocApache Axis 1.43429Sat Apr 22 18:57:26 BST 2006test.wsdl.jaxrpchandler

ClientHandler

public class ClientHandler extends Object implements javax.xml.rpc.handler.Handler

Fields Summary
private static final String
_actorURI
Constructors Summary
public ClientHandler()
Constructor for ClientHandler.

	   	 
	  
		super();
	
Methods Summary
public voiddestroy()

see
javax.xml.rpc.handler.Handler#destroy()

	
public javax.xml.namespace.QName[]getHeaders()

see
javax.xml.rpc.handler.Handler#getHeaders()

		return null;
	
public booleanhandleFault(javax.xml.rpc.handler.MessageContext context)

see
javax.xml.rpc.handler.Handler#handleFault(MessageContext)

		return false;
	
public booleanhandleRequest(javax.xml.rpc.handler.MessageContext context)

see
javax.xml.rpc.handler.Handler#handleRequest(MessageContext)

		System.out.println("Hey - in Handle request");
		try {
			SOAPMessageContext smc = (SOAPMessageContext) context;
			SOAPMessage msg = smc.getMessage();
			SOAPPart sp = msg.getSOAPPart();
			SOAPEnvelope se = sp.getEnvelope();
			SOAPHeader sh = se.getHeader();
			Name name =
			se.createName(
						 "HeaderTest",
						 "AXIS",
						 "http://xml.apache.org/axis");
			SOAPHeaderElement she = sh.addHeaderElement(name);
			she.setActor(_actorURI);
			she.addAttribute(se.createName("counter", "", ""), "1");
			she.addAttribute(se.createName("faultCounter", "", ""), "1");
		} catch (Exception e) {
			e.printStackTrace();
		}

		return true;
	
public booleanhandleResponse(javax.xml.rpc.handler.MessageContext context)

see
javax.xml.rpc.handler.Handler#handleResponse(MessageContext)

		System.out.println("Hey - in Handle response");
		try {
			String counter = null;
			String faultCounter = null;

			SOAPMessageContext smc = (SOAPMessageContext) context;
			SOAPMessage msg = smc.getMessage();
			SOAPPart sp = msg.getSOAPPart();
			SOAPEnvelope se = sp.getEnvelope();
			SOAPHeader sh = se.getHeader();
			SOAPBody sb = se.getBody();
			Name name =
			se.createName(
						 "HeaderTest",
						 "AXIS",
						 "http://xml.apache.org/axis");
			Iterator iter = sh.extractHeaderElements(_actorURI);
			while (iter.hasNext()) {
				SOAPHeaderElement she = (SOAPHeaderElement) iter.next();
				counter =
				she.getAttributeValue(se.createName("counter", "", ""));
				System.out.println(
								  "The counter in the element sent back is " + counter);

				faultCounter =
				she.getAttributeValue(se.createName("faultCounter", "", ""));
				System.out.println(
								  "The faultCounter in the element sent back is " + faultCounter);

			}

			if ((counter != null) && (counter.equals("3")) && (!sb.hasFault())) {
				JAXRPCHandlerTestCase.completeRoundtrip();
			}

			if ((faultCounter != null) && (faultCounter.equals("3")) && (sb.hasFault())) {
				JAXRPCHandlerTestCase.setFaultRoundtrip(Integer.parseInt(faultCounter));
			}


		} catch (Exception e) {
			e.printStackTrace();
		}

		return false;
	
public voidinit(javax.xml.rpc.handler.HandlerInfo config)

see
javax.xml.rpc.handler.Handler#init(HandlerInfo)