axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shantanu Sen <s...@pacbell.net>
Subject Client side JAX-RPC handler setup question
Date Fri, 06 Aug 2004 08:14:32 GMT
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