Thursday, March 24, 2011

JAX-WS with JBoss 6 Day 5 : Asynchronous

An asynchronous invocation of a Web service sends a request to the service endpoint and then immediately returns control to the client program without waiting for the response to return from the service.


JAX-WS asynchronous Web service clients consume Web services using either the callback approach or the polling approach.

Using a polling model, a client can issue a request and receive a response object that is polled to determine if the server has responded. When the server responds, the actual response is retrieved.

Using the callback model, the client provides a callback handler to accept and process the inbound response object. The handleResponse() method of the handler is called when the result is available.

Both the polling and callback models enable the client to focus on continuing to process work without waiting for a response to return, while providing for a more dynamic and efficient model to invoke Web services. Polling invocations are valid from Enterprise JavaBeans™ (EJB) clients or Java Platform, Enterprise Edition (Java EE) application clients. Callback invocations are valid only from Java EE application clients.

1. Let's make our hello web service sleep for a while


2. Test case to use hello web service asynchronously , Person class is in Day 3 example.


Alternatively, you can generate asynchronous supported client with jaxws:enableAsyncMapping applied.

1. Create a JAX-WS binding file named jaxws-binding.xml


2. Generate web service client using below command
wsconsume -k -b jaxws-binding.xml -p jboss.ws.hello.client http://localhost:8080/iJBossWS/ws/testService?wsdl

3. Check your client interface that below 3 method are generated

No comments: