This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes one-way invocations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "one-way invocations" Watch "one-way invocations" New topic
Author

one-way invocations

Guadalupe Ortiz
Ranch Hand

Joined: Sep 12, 2003
Posts: 74
I know how a a client can do a one -way invocation to a service in JAXRPC. But, what about if I want the client to receive a message for other service which he has not invoked. Is it possible? How the client expects the answer? How the remote service sends the this answer?
Any help is grateful,
Guadalupe
Dave Clark
Ranch Hand

Joined: Feb 16, 2005
Posts: 52
if you want 2 one-way calls you're basically doing 'psudo-synchronous' request-reply invocations. All you have to do is let your server make on invocation on your client via a callback interface - your client effectively becomes a server also, and your server also becomes a client.

presumably you have many more servers than clients, and usually you don't want to have to configure each of your servers to know about your clients. So all you have to do is pass from your client to your server, the URL of the callback interface / web service where your server can send results back to your client once it has these results. Your client doesn't wait for results - it just processes them when it gets them.

And this approach works equally well whether your making invocations over SOAP/HTTP or SOAP/JMS.

cheers,

Dave.


Dave Clark<br />Senior WebSphere Architect<br /><a href="http://www.versant.com" target="_blank" rel="nofollow">Versant Open Access - JDO2 & EJB3</a>
Guadalupe Ortiz
Ranch Hand

Joined: Sep 12, 2003
Posts: 74
Thanks for your reply, but how do you implement a callback interface? Is it possible to do it with JAXRPC?
Thanks again for your attention,
Gobellot
Dave Clark
Ranch Hand

Joined: Feb 16, 2005
Posts: 52
I should have said 'many more clients than servers' before :-)

If you're using web services / JAX-RPC between your client and server for the forward call, it makes sense to use it also for your callback interface. This is easy with something like CORBA or RMI, because the ORB/RMI infrastructure for a client includes the server infrastructure as well.

The catch with web services is that you basically need to run an HTTP server on your client. So you'll end up with a more heavyweight client, since you'll effectively be running a web container / (i.e. a servlet engine) on both your client and server.

The next version of JAX-RPC - v2.0 - will include asynchronous web services which will effectively let you call a service and either have the service call back the client, or allow the client to poll the server for the results. You'll have to wait for J2EE 5 for this though (ie not this year).

If running a web container (ie HTTP server) on your clients is out, then maybe you should look at either RMI or JMS as the transport rather than web services.

hope the above helps,

cheers,

Dave.
Guadalupe Ortiz
Ranch Hand

Joined: Sep 12, 2003
Posts: 74
I have a server engine in both sides, service and client, but I still have some doubts.
By now I am implementing a jsp client whihc uses JAXRPC to invoke a remte JAXRPC service. So my questions would be:
i) If I still have my jsp client how do I update the information in the page when "i receive" the invocation?
ii) I am sorry I am not familiarized with servlets as I was using JAXRPC clients and services from the begining. I think that I must build the SOAP message to send in the servlet, but I was trying it and I get an error about the opperation name, but anyway I do not kow if that is what i have to do. Please tell me if I am wrong in my steps.
Thank-you very much for your help,
Guadalupe
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

To do async you need to be running web services on both the server and the client. You need two wsdl's, one for the intial request and another for the callback.
Google "WS-I Basic Callback", here is one hit: http://www-128.ibm.com/developerworks/webservices/library/ws-iuse/


Please ignore post, I have no idea what I am talking about.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Couple of other thoughts.

Given a choice WebServices shouldn't be you first choice when trying to solve a problem which has async communications.

To get the response from an async request you need to 1] wait, or 2] check back later. Servlets are not the best choice when you want to wait or check back later.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: one-way invocations
 
Similar Threads
Consuming a web service using Java
two j2ee application called from web app
how can i make one service to call another service?
web service not available
web service client should send file