ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gene...@ws.apache.org
Subject [Apache Web Services Wiki] New: FrontPage/Axis/AxisClientConfiguration
Date Tue, 11 Jan 2005 11:14:57 GMT
   Date: 2005-01-11T03:14:57
   Editor: ToshiyukiKimura
   Wiki: Apache Web Services Wiki
   Page: FrontPage/Axis/AxisClientConfiguration
   URL: http://wiki.apache.org/ws/FrontPage/Axis/AxisClientConfiguration

   Importing old wiki ...

New Page:

##language:en

'''How do I setup handlers in Axis clients?'''

When instantiating a Service-object, you can provide your own {{{ EngineConfiguration }}}.
There are several ways to build a configuration of your desire: 

 * Use WSDD-XML like for server-side deployment-descriptors 
This example configures the {{{ SimpleSessionHandler }}} in the request- and response-flow
of a HTTP-transport-chain: 

{{{
     <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="..." > 
       <handler type="java:org.apache.axis.handlers.SimpleSessionHandler" 
                name="SimpleSessionHandler"/> 
       <transport name="http" 
                  pivot="java:org.apache.axis.transport.http.HTTPSender"> 
         <requestFlow><handler type="SimpleSessionHandler"/></requestFlow>

         <responseFlow><handler type="SimpleSessionHandler"/></responseFlow>

       </transport>" 
     </deployment> 
}}}
 
The code to get an {{{ EngineConfiguration }}} from this given as a String: 

{{{
     EngineConfiguration clientConfig = (EngineConfiguration) new ["XMLStringProvider"](WSDDString);

}}}
 
 * Build your own class, that implements the {{{ EngineConfiguration }}} interface 
   
 * Use an existing {{{ EngineConfiguration }}}-class that is configurable in parts 
The {{{ SimpleProvider }}}, for example, allows deployment of Transport chains The following
example does about the same as the WSDD above: 

{{{
     import org.apache.axis.configuration.SimpleProvider; 
     import org.apache.axis.EngineConfiguration; 
     import org.apache.axis.Handler; 
     import org.apache.axis.SimpleChain; 
     import org.apache.axis.SimpleTargetedChain; 
     import org.apache.axis.handlers.SimpleSessionHandler; 
     import org.apache.axis.transport.http.HTTPSender; 
     import org.apache.axis.transport.http.HTTPTransport; 

     EngineConfiguration createClientConfig() 
     { 
       SimpleProvider clientConfig=new SimpleProvider(); 
       Handler sessionHandler=(Handler)new SimpleSessionHandler(); 
       SimpleChain reqHandler=new SimpleChain(); 
       SimpleChain respHandler=new SimpleChain(); 
       reqHandler.addHandler(sessionHandler); 
       respHandler.addHandler(sessionHandler); 
       Handler pivot=(Handler)new HTTPSender(); 
       Handler transport=new SimpleTargetedChain(reqHandler, pivot, respHandler); 
       clientConfig.deployTransport(HTTPTransport.DEFAULT_TRANSPORT_NAME,transport); 

       return clientConfig;    
     } 
}}}
 
When using {{{WSDL2Java-generated code}}}, the {{{ XYServiceLocator }}} (that extends Service)
does not provide a constructor to give the configuration. If you do not want to modify generated
code, you can work around this the following way: 

{{{
       EngineConfiguration clientConfig=getClientConfig(); 
       ["XYServiceLocator"] service=new ["XYServiceLocator"](); 
       service.setEngineConfiguration(clientConfig); 
       service.setEngine(new AxisClient(clientConfig)); 
       XY myservice=service.getmyservice(); 
}}} 

Mime
View raw message