FileDocCategorySizeDatePackage
ProxyService.javaAPI DocApache Axis 1.42981Sat Apr 22 18:56:52 BST 2006samples.proxy

ProxyService

public class ProxyService extends Object
Proxy sample. Relays message on to hardcoded URL. Soon, URL becomes configurable (via deployment?!); later, URL becomes specifiable in custom header.
author
Rob Jellinghaus

Fields Summary
Constructors Summary
Methods Summary
public voidproxyService(org.apache.axis.message.SOAPEnvelope env1, org.apache.axis.message.SOAPEnvelope env2)
Process the given message, treating it as raw XML.

        try {
            // Get the current Message Context
            MessageContext msgContext = MessageContext.getCurrentContext();
            
            // Look in the message context for our service
            Handler self = msgContext.getService();
            
            // what is our target URL?
            String dest = (String)self.getOption("URL");
            
            // use the server's client engine in case anything has 
            // been deployed to it
            Service service = new Service();
            service.setEngine( msgContext.getAxisEngine().getClientEngine() );
            Call    call = (Call) service.createCall();

            SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
            // !!! FIXME
            //service.getEngine().deployTransport("tcp", c);
    
            // add TCP for proxy testing
            call.addTransportPackage("samples.transport");
            call.setTransportForProtocol("tcp", TCPTransport.class);
            
            // NOW set the client's URL (since now the tcp handler exists)
            call.setTargetEndpointAddress(new java.net.URL(dest));
    
            call.setRequestMessage(msgContext.getRequestMessage());
            
            call.invoke();
            
            Message msg = call.getResponseMessage();

            msgContext.setResponseMessage(msg);
        }
        catch( Exception exp ) {
            throw AxisFault.makeFault( exp );
        }