You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by ge...@ws.apache.org on 2005/01/11 12:14:57 UTC
[Apache Web Services Wiki] New: FrontPage/Axis/AxisClientConfiguration
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();
}}}