File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Is it possible to intercept a message ? 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 "Is it possible to intercept a message ?" Watch "Is it possible to intercept a message ?" New topic
Author

Is it possible to intercept a message ?

bhavini patel
Greenhorn

Joined: Dec 23, 2010
Posts: 7
There is a web service in .Net that returns large data. On the client side they intercept the message using SoapExtension and save the data in file and then return blank message to client. Is it possible to do something like this in Java Web Service ? The web service queries the database and returns large amount of data.

I am stuck for past few days....

Thanks!
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Bhavani,
You can use Fiddler tool to inspect SOAP messages including HTTP headers. You can also change message content "on the fly" and issue requests.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
bhavini patel
Greenhorn

Joined: Dec 23, 2010
Posts: 7
I was asking if it could be done programetically ? Inside a java program ?

Thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
Why is this different from the normal SOAP message handling on the client side?

What exactly does
return blank message to client.
mean anyway? How many entities are involved here? one server and one client or what?

Bill
bhavini patel
Greenhorn

Joined: Dec 23, 2010
Posts: 7
One server and one client is involved.

They are saying that the web service in .NET is created so that they use SoapExtension and intercept the message. After the client makes the call, when the data it returned the intercept the SOAP message and get the part in the <data> part and save it to a file on the defined location. Then return the blank message to the client, so that they do not run out of memory...
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

bhavini patel wrote:One server and one client is involved.

They are saying that the web service in .NET is created so that they use SoapExtension and intercept the message. After the client makes the call, when the data it returned the intercept the SOAP message and get the part in the <data> part and save it to a file on the defined location. Then return the blank message to the client, so that they do not run out of memory...


Bhavani,

Help us understand the problem. This is what I understood so far.

1) Client makes the request to service written in .net.
2) Server responds back with SOAP response.
3) Client needs to intercept the response and extract some data out of it and persist it.
4) I did not understand who is returning the blank message to whom and when.

For intercepting the message, you can use the handler mechanism either logical or soap handlers based on your requirement. If you have access to MessageContext, you can access SOAPMessage, SOAPBody, SOAPHeaders etc. Look at MessageContext


Regards
KumarRaja

bhavini patel
Greenhorn

Joined: Dec 23, 2010
Posts: 7
I am sorry that I cannot make it clear enough....

Currently they have web service in .NET written in C#. The web service queries the database and returns the results. The results are huge so if the client gets all the results at the same time it will have memory issues. They are telling me that in the .NET client, when it makes the call, the message is intercepted and the stream is persisted. and the data is written to a file. This way the client does not get too much data back. The data is stored in a file on the client side. They are saying they have used SoapExtension in C#.

They want me to create similar web service in Java. Also write a client in java that will intercept the message and store the result in the file.

I am new to web services, so might not be able to explain properly.. Thanks for your help!!! i will start looking in to MessageContext.

Thanks again...hope i can get more information.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
Then return the blank message to the client, so that they do not run out of memory...


Why not just drop the message?

What exactly is this "client" that wants to see a SOAP message that is blank, and how is it different from the "client" that grabs the data and writes the file? If both these "clients" are the same Java program why is there a problem?

Bill
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you looked at JAX-WS handlers?
Using handlers, you can intercept messages to/from JAX-WS web services both on the client and server side.
For an introduction, look at, for example, this article: http://www.javaworld.com/javaworld/jw-02-2007/jw-02-handler.html
There surely are many other articles out there, use your favourite search engine to find them - alternatively take a look at section 9.5 in my SCDJWS study notes, which can be downloaded at http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
bhavini patel
Greenhorn

Joined: Dec 23, 2010
Posts: 7
This is what the .NET developer says

Since .NET has the concept of WebserviceExtensions, I can hook into the network stream on the receipt of the SOAP envelope and strip out the data portion of the response. That data portion is streamed straight to disk.


They are asking me if something similar to this can be done in java.

Thanks
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
bhavini patel wrote:This is what the .NET developer says
Since .NET has the concept of WebserviceExtensions, I can hook into the network stream on the receipt of the SOAP envelope and strip out the data portion of the response. That data portion is streamed straight to disk.

It sounds to me as if this is indeed doable using JAX-WS handlers in Java. In a handler you have access to either the entire SOAP message or the payload, depending on how you choose to develop the handler.
Best wishes!
bhavini patel
Greenhorn

Joined: Dec 23, 2010
Posts: 7
Thanks! I will try that out...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to intercept a message ?