aspose file tools*
The moose likes Web Services and the fly likes Client side soap message handlers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Client side soap message handlers" Watch "Client side soap message handlers" New topic
Author

Client side soap message handlers

Vasavi Vadlamudi
Greenhorn

Joined: Oct 15, 2004
Posts: 2
Hello,

I am trying to intercept a soap response coming from a web service (Deployed on Weblogic 8.1) on the client side before it gets converted to a java response object. I have tried extending weblogic.webservice.GenericHandler available in Weblogic to do so. More specifically, I wrote a handler implementing the handleResponse() part of weblogic.webservice.GenericHandler, and then registered my SoapMessageHandler with the client as follows:

QName portName = new QName( <targetNameSpaceURI>, <portName> ;
HandlerRegistry registry = service.getHandlerRegistry();
List handlerList = new ArrayList();
handlerList.add( new HandlerInfo( <SoapMessageHandler classname>, null, null ) );
registry.setHandlerChain( portName, handlerList );

My understanding is that the SoapMessageHandler should always be invoked when a soap response is received, but it doesn't happen. The handler is not invoked.

Is there something more I need to write or configure to make this work? Could this be because the client is not a J2EE application? Could someone help me with this?

Thank You,
Vasavi
Roger Duchemin
Greenhorn

Joined: Sep 29, 2004
Posts: 11
Hi Vasavi,

You probably need to tell the HandlerChain what headers you handler understands and is able to process, either:

- as the QName[] array return type of the getHeaders() method in you Handler implementation,
- or as a QName[] array in third parameter when you create the handlerInfo object that you put in your HandlerChain, instead of null:
QName[] headers = new QName[]{ new QName(anURI, aLocalName)};
handlerList.add( new HandlerInfo( <SoapMessageHandler classname>, null, headers ) );
registry.setHandlerChain( portName, handlerList );
- or both.

The first solution being clearly the best one.

HtH


SCJP1.1,SCJD,SCEA(part1,beta),SCJP1.2,SCWCD(Beta),SCBCD(Beta),SCDJWS(Beta)
Navi Singh
Ranch Hand

Joined: Jul 24, 2002
Posts: 80
Hi Guys,
i am have the same issue.But am at a very early stage.
Don't know where/what/how to "Use the Handler's".
Also am using WSAD5.1.1 as the IDE..so..don't know where to start.
Could u guys guide me to any good tutorial to this "Handler's" topic.

Thanks,
-Navi
Vasavi Vadlamudi
Greenhorn

Joined: Oct 15, 2004
Posts: 2
Hi Roger,

Thank you very much for your reply. I tried what you have suggested. I added the request and response headers to HandlerInfo. The problem is not solved. I put some system.out statements in the handler's init(), handleRequest(), handleResoponse(), and getHeaders() methods. None of them are showing up. This would mean the handler is not even initialized. I am having doubts on the correctness of the QName I am associating with the service in the handlerChain. I picked up the nameSpaceURI and the local part for the QName from the WSDL for the service. For example, from the following entry:

xmlns:tns="com.resource.temp/service/MyService/ws"
....
....
<binding name="MyServiceSoap"
type="tns:MyServicePort">

URI = "com.resource.temp/service/MyService/ws"
local part = MyServicePort

Do you think this is ok? I don't know what else could be wrong.

Thanks,
Vasavi
[ October 17, 2004: Message edited by: Vasavi Vadlamudi ]
Roger Duchemin
Greenhorn

Joined: Sep 29, 2004
Posts: 11
Hi Vasavi,

If the init() method of your handler is not called, it's certainly because the HandlerChain object has not been created by your app server.
You need to use configuration files to tell an app server (before it starts) that you want a HandlerChain object, and what handlers you put in with their init parameters and so on.
I don't know the conf files for weblogic. However, in JWSDP it is the config.xml file on the client side, or in J2EE the webservices.xml file.
In JWSDP, if you use a stub client, you don't need to initialize a HandlerRegistry with the code you showed in you first post, but it's necessary to do it with a "proxy" or "call" client.
You may take a look at this link :
http://java.sun.com/webservices/docs/1.3/tutorial/doc/JAXRPC7.html#122942

In the message handler class, be sure to implement the getHandlers() method returning an array of QNanes. Those QNames are the qualified names of headers entries, that is the element names of immediate child elements of the SOAPHeader element.
This way, each handler can declare the element names it intends to process.
As WS are interoprable, you can also write a simple standalone app client with JWSDP in order to test your service.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client side soap message handlers