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 Asynchronous server-side web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Asynchronous server-side web service" Watch "Asynchronous server-side web service" New topic
Author

Asynchronous server-side web service

dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
hi all,

can anyone lead me to a good example / tutorial of how to create an Asynchronous server-side web service?

many thanks for any help
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Make sure to remove the 'output' tag in the wsdl. (Therefore, any synchronous sample that you have will do; just remove the 'output'; also your interface would have return value of 'void')

If you do have an output, make sure you return immediately to the calling program; for example, pass the processing to an MDB, thereby your web service wont wait for it to finish and return immediately, and your web service will return asap to the client.
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
hi there, thanks for the reply

i'm not really understanding what i need to do, do you have an example?

many thanks
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
if i remove all the 'ouput' tags - what next?

do i need to have a messaging service like JMS?

all my web services use axis, can i use this and not have to use anything else or will i hvae to use axis with somthing like JMS?

many thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
Does "asynchronous" mean that a response will eventually be sent, or that no response will be sent?

You don't need a messaging service, but if a response is to be sent eventually, you'll need to make the client accessible somehow so that Axis can send the response to the client. Since we're talking about WS, that might mean that the client runs Axis as well (maybe the embedded SimpleAxisServer).


Ping & DNS - my free Android networking tools app
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
yes a response will be send evetually.

but i'm not sure how i write my server-side code.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
The server will likely start its processing in a new thread, and close the client connection as soon as possible. For delivering the result the server will act as a WS-client, and the client that originated the request acts as WS-server. That's why the server needs to know how to reach the client, so that it can deliver the response. In a synchronous scenario, the server doesn't need to know this, because the connection to the client is still open for the response.
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
Thanks for your help, I'm not undestaning how the Client will eventually get the response from the web service without calling the web service method again

e.g

WS method

public static String getString(String s)
{ return "hello " + s; }

Client calls WS method -> getString("bob")

What happens next? the web services is invoked and the WS returns hello bob.

This is synchronous. How do i make it asynchronous? What do i need to do in my web service method getString to return heelo bob some time later?

Sorry for my lake of understanding

many thanks for your help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
Asynchronous implies that the responding side (the server) will call back the client later with the result. In effect, both sides act both as WS client and WS server. If you want to avoid the overhead of having a WS server as part of the client, you'd be better off with a scheme like you suggest, where you have a second call for retrieving the results. Of course, since the client makes that call, you will not know when the result is ready, so you might be calling too early, or too late.
[ June 19, 2006: Message edited by: Ulf Dittmer ]
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by dale conn:
Thanks for your help, I'm not understanding how the Client will eventually get the response from the web service without calling the web service method again


Well that's one possibility - i.e. on the initial service request the server returns a Correlation Identifier that the client uses on subsequent HTTP requests to determine the status of the original service request and finally is used to retrieve the result. Other possibilities:
- Implement the client as a web service and submit the "return" endpoint address as part of the request. That way the "result" has somewhere to be delivered.
- Use a different "channel" to return the result by: JMS, SMTP, etc.

See
6.3.2 Enterprise Beans and JMS Approach
8.2.1.1 Communication Technologies
8.4.3 Refactoring Synchronous to Asynchronous Interactions

Asynchronous operations and Web services, Part 1: A primer on asynchronous transactions
Asynchronous operations and Web services, Part 2
[ June 19, 2006: Message edited by: Peer Reynders ]
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
If I have a server-side web service like this

Jave code - public static String getString(String s){return "hello " + s;}

WSDL -



Then a client calls the server-side web service. Is it up to the Client whether they call it synchronous or asynchronous? I'm not writing a Client, I'm writing a server-side webservice, do I have to do anything special server-side?

I'm reading this article http://dev2dev.bea.com/pub/a/2005/03/callback_clients.html and it says Asynchronous Web Services. What do they mean by this? Do they mean a server-side Asynchronous web service? If so, can anyone give me a basic example of a server-side Asynchronous Web Service?

Thanks for nay help
[ June 20, 2006: Message edited by: dale conn ]
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by dale conn:
Is it up to the Client whether they call it synchronous or asynchronous?


No, the WSDL states that the communication is synchronous, i.e. the client has to wait for the result as part of the HTTP-response to the HTTP-request.

Originally posted by dale conn:
I'm reading this article http://dev2dev.bea.com/pub/a/2005/03/callback_clients.html and it says Asynchronous Web Services. What do they mean by this?


It means that the "client" is actually a web service and the "client-service" communicates it's endpoint address to the "server-service", so that the "server-service" can return the result later to the "client-service" endpoint.
This is a solution particular to Weblogic and it's tool's probably generate the necessary code for both the client and the server. As such it should probably not be used unless you have full control over the client. You could make the generated client code available - however the client would have to be willing to open access to the client endpoint through the firewall for it to work.
[ June 20, 2006: Message edited by: Peer Reynders ]
dale conn
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
What would be the best route to go down?

Both the server-side web-service and Client code are written in house.

server-side is java and axis, client is vb
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by dale conn:
client is vb


Is the client implemented in VB 6 or VB.NET?

A pure VB6 client is more or less limited by the functionality of the Microsoft SOAP Toolkit Version 3.0.
You should probably look into implementing a .NET assembly that uses more up-to-date WS technology to access the web service. Then expose that .NET assembly as a COM component through a COM Callable Wrapper (CCW) to the VB6 client. See Exposing .NET Framework Components to COM.

(Hmmm...this is starting to look like this topic zipping msg before sending)

If you are unfamiliar with web services, trying to create a VB client that can talk to this type of Weblogic "asynchronous web service" may prove to be too much of a challenge.I'm quite certain that you won't be able to simply point VS.NET to the resulting WSDL and expect the generated code to work right off the bat. I'd suspect that a lot of manual intervention will be required to get that to work. It's probably easier to simply define separate endpoints for
  • request submission - which returns a correlation identifier
  • status query - which uses the correlation identifier and could return a progress indication
  • result retrieval - which uses the correlation identifier

  • and have the VB client poll regularly to determine whether the result is ready for retrieval.
    [ June 21, 2006: Message edited by: Peer Reynders ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Asynchronous server-side web service
     
    Similar Threads
    regarding Asynchronous request-response feature
    JAX-WS Async call
    Asynchronous Web service call
    Question on Asynchronous web service call using document style.
    Asynchronous call in the Server side?.,