aspose file tools*
The moose likes Web Services and the fly likes Question about design of WS clients and their handlers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Question about design of WS clients and their handlers" Watch "Question about design of WS clients and their handlers" New topic
Author

Question about design of WS clients and their handlers

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello,

I have a WS client (i.e. a servlet) and a corresponding message handler. I simply want to retrieve IN the client a variable FROM the handler. Please let me know how to do that.

Here is a snippet from the handler:



What I want to achieve specifically is retrieving in my servlet an attachment that is available in my handler.

Any help immensely welcome.

Julien.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Which one do you need to access in your client, the attachment or one of MessageContext properties?

If you need the attachment, then it should be available in the response variable in your client; the same way you extracted it in the sample code you posted.

If what you need is an object in the handler, or a property in its MessageContext, I also am not aware how. But one way ( a dirty way ), is to chunk them in, into the mime soap. You may need to update other items like the wsdl, for this new info in the message.
[ May 27, 2006: Message edited by: Jesus Angeles ]
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
Also, usually, only the headers are touched in the handlers. It is not an adviseable design to touch other than the headers in the handlers; but yes, you have full access to the whole message. So there is nothing stopping you from doing so.
[ May 27, 2006: Message edited by: Jesus Angeles ]
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello Jesus and thanks a lot for replying,

However I had a look at the response class and was not able to find anything that would allow me to get my attachement.

Here is the client (a servlet). The method is just a dummy method and does not do anything. What is more it is ill-named.


Here is the client-side handler:



Here is the endpoint:



Here is the endpoint-side handler:



Do you see my point??

Julien.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
I see. You are passing the attachment from server handler to client handler. ...sort of, a trojan horse...hiding inside the message...not defined in the wsdl

The service can easily get its server handler/s MessageContext; however, I havent seen any connection between the client and the client handler/s MessageContext.

You might need to find a way, like write the attachment first to a file, and the servlet(client) will read that file.
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Yes you're right. That's what I suspected: what I want to achieve is impossible. I am a beginner in WS and I just assumed that attachements had to be dealt with through handlers: erroneous assumption.
Thanks a lot for replying.
I am going to do some redesign.
Julien.
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello,
Has anyone got any idea on how to redesign/refactor the above application in order for a j2ee client to fetch binary data from an endpoint?
Julien.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
Why not try to use ThreadLocal for the client and client's handler. In the client's handler, it generates one object includes you the attachment and set to ThreadLocal. When the client code get response and uses the same ThreadLocal object to retrieve the stored attachment things you saved in client's handler.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about design of WS clients and their handlers