Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Service for Asynchronous Client calls (polling, callback)  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a WebService learner and digging through all this stuff isn't easy with all that maybe-outdated-but-still-usable technology floating around. Here's my thing.

My goal is to create a WebService that can be called to perform a time-consuming task. This should be done asynchronously since the client is required to continue working. On my way to achieve this I have stumbled upon JAX-WS 2.0 and it's possibility to create web services via annotation. It also allows asynchronous calls with the @oneway annotation.

Now, I to my understanding (and from several different sources on the web) it seems like I need a server working synchronously which returns a Response<?> (for a polling approach). For a callback approach it seem to be needing an AsyncHandler and sometimes a Future<?>.

Here's how that is supposed to look:



Here's the endpoint code:



I am using Java 1.6.0_26 and Eclipse Indigo with WTP. I have not actively deployed this code to any server, I am just running this Publisher class above. Everything was working fine until either Response, Future or AsyncHandler are added to the code.

Before that the WSDL was retrievable via http://localhost:8080/services?wsdl. I was able to run a client based on this code using wsimport from a *.bat like this:

wsimport -d ..\src -keep -p test http://localhost:8080/services?wsdl

Now it's giving me this exception, which means I don't even get to the point where my Publisher generates the WSDL:



From what I know this tells me JAXB isn't able to work with these interfaces because it can't translate them. But if that's the case, why do I find tutorials with this code at IBM and Apache Axis 2?


Thanks for your help.
 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
KEY: The features you're looking for is from the Client side only - Client ASYNCHRONOUS invocation.

You will be clarified by these 2 links:
http://jax-ws.java.net/nonav/2.1.4/docs/UsersGuide.html
http://jax-ws.java.net/nonav/2.1.4/docs/asynch.html

Simplified as below:

1.
http://jax-ws.java.net/nonav/2.1.4/samples/fromwsdl/etc/AddNumbers.wsdl
wsimport this wsdl and you (client) can make a SYNCHRONOUS call.

the generated service endpoint interface DO NOT have async methods.


3. if you (client) want to make a ASYNCHRONOUS call to the web service provider (polling or callback)

http://jax-ws.java.net/nonav/2.1.4/docs/asynch.html

In order to generate a service endpoint interface with asynchronous methods the following binding declaration file will be passed to wsimport





These 2 allow you (client) to invoke a web service provider ASYNCHRONOUSLY from the client only.

4. Some IDE will generate these 2 async methods or have an option during the web service client generation to create
these 2 asyn methods.
 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is 1 quick test:

Server side on GlassFish 3x


Client side (eclipse ide, Apache CXF and the binding file for ide for client side artifacts generation)

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!