11.07.2015 Views

Anyframe CXF JAX-WS Plugin

Anyframe CXF JAX-WS Plugin

Anyframe CXF JAX-WS Plugin

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.Asynchronous InvocationAlong with general synchronous invocation, Apache <strong>CXF</strong> supports two types (Polling approach, Callbackapproach) of asynchronous invocation defined in <strong>JAX</strong>-<strong>WS</strong> Spec. In other words, calling Web Services inserver side from client side can be done asynchronously.The characteristics of Polling approach are as follows.• Server) Add method (method name: target method name + "Async") in service interface. In this case,define method whose return type is Response.• Client) To call method existing remotely, call the specific method returning javax.xml.ws.Responseobject without output parameter.• Response object which extended javax.util.concurrency.Future interface is used to check whether theresponse message arrived.The characteristics of Callback approach are as follows.• Server) Add method (method name: target method name + "Async") in service interface. In this case,define method whose return type is Future and input parameter is AsynchHandler.• Client) Need to implement AsyncHandler class.• Client) To call the method existing remotely, call the method defined above, one of whose parametersare in reference relation with callback object of javax.xml.ws.AsyncHandler type.• As soon as response message arrives to client, Apache <strong>CXF</strong> runtime environment recalls AsyncHandlerobject to transfer response message to response message contents.The following shows which task to be done on server and client side to use Asynchronous MethodInvocation. Let's look into an example for the two types (Polling approach and Callback approach) ofasynchronous invocation.5.1.Server ConfigurationBy using tool provided in Apache <strong>CXF</strong>, it supports asynchronous invocation of Web Services. The followingis an example of how asynchronous invocation is possible using tool.If tool is not yet prepared, download Apache <strong>CXF</strong> from download page [http://cxf.apache.org/download.html] and extract the file to use tool existing in bin folder under root folder.5.1.1.SamplesCreate <strong>WS</strong>DL file by using java2ws Tool targeting interface class of Movie Service to exposeto Web Service. After creating <strong>WS</strong>DL, create java source codes which enable asynchronousinvocation (classes under anyframe.sample.movie.jaxws.asynch.asynch_soap_http package (SEI,WebServiceClient, complex type classes)) by using <strong>WS</strong>DL file and asynch_binding.xml file throughwsdl2java Tool. In this case there is no need to use java2ws Tool if you already have <strong>WS</strong>DL file.• Temporary Interface ClassThe following is a part of MovieServiceAsynch.java which developed interface class of Movie Service.As it implements Web Services using <strong>JAX</strong>-<strong>WS</strong> Frontend model, make sure to define @WebServiceAnnotation in the top of interface class. Define findMovieListAll() as interface method and client callsthis method asynchronously. In fact, this interface is not used. It is developed to create <strong>WS</strong>DL file.The one that is used is the interface class created from <strong>WS</strong>DL file.30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!