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 Web service interface help 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 "Web service interface help" Watch "Web service interface help" New topic
Author

Web service interface help

Matthew Snow
Ranch Hand

Joined: May 02, 2007
Posts: 82
I'm still pretty green when it comes to interfacing with a remote web service and was hoping I could be pointed in the right direction. I need to communicate with a remote web service on a recurrent basis. The transactions will consist of commands being sent via URL parameters as well as various data in xml format. Also, responses back will be in xml format as well. Most of these exchanges will require multiple back-and-forth communications. For example, the following scenario is likely:

Login request with credentials (data in xml format) <--> Result returned in xml format
Desired transaction sent with data in xml format <--> Result returned in xml format
Logout request with credentials <--> result returned

Where I'm getting fuzzy is how to kick off these transactions as I want them to be automated on a recurrent basis, possibly through crontab. Also, if my side needs to be a web service, just so I can get access to a HTTPServletRequest and Response objects from a servlet container such as Tomcat, how would I make it stateful since each exchange will require multiple transactions to complete, as you can see in the example? Thanks in advance.


When you break the big rules, you get a lot of little rules.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
First you speak about web services, then you speak about sending parameters using URL parameters.
Have you decided on what kind of web service you want to use?
Both SOAP and REST web services can use the underlying servlet technology to maintain state.
Another option is to use some kind of correlation identifier that clients obtain as a result of the first call in the series of calls that are to be considered as in one and the same transaction.
To have those transactions you described occur on a regular basis, you can indeed use cron and invoke your Java client program.
Another option is also to use the Quarz scheduler - it all depends on whether you want your client to run constantly or only to run when to perform a transaction.
Best wishes!
Matthew Snow
Ranch Hand

Joined: May 02, 2007
Posts: 82
I am able to connect to the web service with an Httpclient and am getting xml data back so I assume that would be the way to go. I'm not familiar with a correlation identifier or how to put xml data into the client when I send a request over. Is there any good O'Reilly books you could suggest that I could look over? Thanks.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Correlation identifier is, for instance, a unique long number that the client obtains after the first request to the service.
This identifier is the enclosed in each subsequent request and the service uses it to retrieve the client's state.
You can connect to SOAP and REST web services using the Apache HttpClient, so it does not tell me much besides the fact that you use HTTP transport.
In section 4.10 of a document I've written, there is a description on how to implement stateful SOAP web services and clients.
The document can be found at: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web service interface help