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.
Joined: Oct 04, 2006
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.
Joined: May 02, 2007
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.
Joined: Oct 04, 2006
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!