axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shantanu Sen <s...@pacbell.net>
Subject Re: Client side JAX-RPC handler setup question
Date Tue, 10 Aug 2004 17:48:02 GMT
Yves,

Yes this is a much cleaner approach. I used this
approach but with modifications to suit JAX-RPC
handlers, since call.setClientHandlers works with axis
handlers. I did a getHandlerRegistry().setHandlerChain
in the constructor and then in the createCall I had to
invoke the super.createCall with the portTypeQName

Thanks a lot for your help.

Shantanu

--- Yves Langisch <lists@langisch.ch> wrote:

> Shantanu,
> 
> With Axis handlers I do it as follows:
> 
> Creating class CustomService:
> 
> public class CustomService extends Service {
> 
>     private Integer timeout = null;
>     private SimpleChain reqHandlers = null;
>     private SimpleChain respHandlers = null;
> 
>     public Call createCall() throws ServiceException
> {
>         org.apache.axis.client.Call call =
> (org.apache.axis.client.Call) 
> super.createCall();
> 
>         if (this.getTimeout() != null) {
>             call.setTimeout(this.getTimeout());
>         }
> 
>         if (this.getReqHandlers() != null ||
> this.getRespHandlers() != null) {
> 
>            
> call.setClientHandlers(this.getReqHandlers(), 
> this.getRespHandlers());
>         }
>         return call;
>     }
> ....
> 
> The createCall() method is called by the stub during
> invocation of your 
> method.
> 
> Usage of the stub:
> 	CustomService cservice = new CustomService();
> 	cservice.setTimeout(timeoutInteger);
> 	cservice.setReqHandlers(reqChain);
> 
> 	XYZStub stub = new XYZStub(uri, cservice);
> 	stub.method1();
> 
> Hope this help.
> Yves
> 
> On Friday 06 August 2004 10:14, Shantanu Sen wrote:
> > What is the preferred way of adding client side
> handlers given the
> > following constraints:
> >
> > I only have the generated stub class - I
> instantiate it using reflection
> > and invoke the relevant method. So, I cannot do a
> > ServiceFactory.createService and then set the
> handlerinfochain etc as shown
> > in the jaxrpchandler sample and as recommended by
> the JAX-RPC spec.
> >
> > Also, I cannot use the client side wsdd - I need
> to set the handlers
> > programmatically.
> >
> > So, I was tinkering with the following approach. I
> already have a custom
> > EngineConfigureationFactory which I use to set my
> custom transport when
> > invoking a Web Service using an Axis client. I can
> try to reuse this class
> > to set the WSDDJAXRPCHandlerInfoChain on the
> service.
> >
> > 1. Set a custom EngineConfigurationFactory using
> > properties.put("axis.EngineConfigFactory",
> "myfactory")
> >
> > 2. myfactory returns a custom EngineConfiguration
> (MyClientEngineConfig) on
> > the getClientEngineConfig() call.
> >
> > 3. The MyClientEngineConfig extends SimpleProvider
> >
> > In this class I need to somehow set the
> WSDDJAXRPCHandlerInfoChain on the
> > Service. I have not been successful yet. Here is
> the class
> > ===========================
> > public static class MyClientEngineConfig extends
> SimpleProvider {
> >
> > WSDDJAXRPCHandlerInfoChain handlerInfoChain;
> >
> > public MyClientEngineConfig() {
> > deployTransport("http", new
> SimpleTargetedChain(new MyHttpTransport()));
> > }
> >
> > public void configureEngine(AxisEngine engine)
> throws
> > ConfigurationException {
> super.configureEngine(engine);
> >
> > // just test it for now
> > ArrayList listOfHandlerInfos = new ArrayList();
> > WSDDJAXRPCHandlerInfo info = new
> WSDDJAXRPCHandlerInfo();
> > info.setHandlerClassName("MyClientHandler");
> > listOfHandlerInfos.add(info);
> >
> > handlerInfoChain = new
> WSDDJAXRPCHandlerInfoChain();
> >
>
handlerInfoChain.setHandlerInfoList(listOfHandlerInfos);
> >
> > }
> >
> > public SOAPService getService(QName qname) throws
> ConfigurationException {
> > SOAPService s = super.getService(qname);
> > if (s != null) {
> > s.setOption(Constants.ATTR_HANDLERINFOCHAIN,
> handlerInfoChain);
> > } else {
> > // Create SOAP Service here and set the option ?
> Is this a good approach?
> > }
> >
> > return s;
> > }
> > ===================
> >
> > Is there a better way of doing this? The ideal
> thing would have been to set
> > the handler(s) on the MyClientEngineConfig and let
> it do it's job. But
> > unfortunately, SimpleProvider only deals with Axis
> handlers - not JAX-RPC
> > handlers.
> >
> > Alternatively I can create a XML fragment that
> contains the content of
> > client-config.wsdd then use WSDDDocument to read
> it in the configureEngine
> > (basically similar to what the FileProvider does).
> This should also work.
> > But this also seems rather convoluted - why do I
> have to read a doc and
> > setup my service configuration every time I make a
> call? I can probably
> > cache the WSDDDocument for all calls through a
> specific client. But is
> > there a better approach?
> >
> > Any suggestions will be highly appreciated.
> >
> > Thanks,
> > Shantanu
> 


Mime
View raw message