FileDocCategorySizeDatePackage
ServerHandler.javaAPI DocApache Axis 1.43493Sat Apr 22 18:57:28 BST 2006test.wsdl.jaxrpchandler

ServerHandler

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

Fields Summary
private int
_counter
private int
_faultCounter
public static final String
_actorURI
Constructors Summary
public ServerHandler()
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)

		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.addAttribute(se.createName("faultCounter","",""), new Integer(_faultCounter +1).toString());
			she.setActor(_actorURI);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return true;
	
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");
			Iterator iter = sh.extractHeaderElements(_actorURI);
			while (iter.hasNext()) {
				SOAPHeaderElement she = (SOAPHeaderElement) iter.next();
				String counter = she.getAttributeValue(se.createName("counter","",""));
				_counter = Integer.parseInt(counter) + 1;

				String faultCounter = she.getAttributeValue(se.createName("faultCounter","",""));
				_faultCounter = Integer.parseInt(faultCounter) + 1;			// Increment it to 2
			}
		} 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 {
			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.addAttribute(se.createName("counter","",""), new Integer(_counter +1).toString());
			she.setActor(_actorURI);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	
public voidinit(javax.xml.rpc.handler.HandlerInfo config)

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