Dear Daniel,
Finally it worked. Thank you for your support to both you and André. The trick was the SEi, in particular the UseAsyncMethod on the implementation and the @ResponseWrapper notation on the synch method of the interface. BR, Giovanni De: Daniel Kulp [via CXF] [mailto:[email protected]] Enviada: 8 de janeiro de 2015 15:13 Para: gido Assunto: Re: Async Calls That interface is not the one generated from the wsdl. As I said, on the client side, take the generated WSDL and generate an interface and at the very minimum, copy all the methods over to your interface INCLUDING any annotation. In particular, for the Async methods to work, you would HAVE to have the wrapper classes available and the appropriate @ResonseWrapper annotations on the non-async methods. All of the method matching and initial processing is done with the non-Async versions of the methods. The annotations and such MUST be 100% correct on those and then the async versions are then matched up to those. Dan > On Jan 8, 2015, at 7:10 AM, gido <[hidden email]> wrote: > > Hi Daniel, > > > > I have also spoken with André Costa Lima (via CXF). I can send you some > other info. > > This is the code that I am going to test: > > > > @WebService > > @SOAPBinding(style = SOAPBinding.Style.DOCUMENT) > > public interface IProsecoService { > @WebMethod(operationName = "startWebService") > > public void start(); > > @WebMethod(operationName = "stopWebService") > public void stop(); > > > > @WebMethod(operationName = "restartWebService") > public void restart(); > > > > @WebMethod(operationName = "pingWebService") > public String ping(); > > > > @WebMethod(operationName = "invokeWebService") > public boolean configure(String Configuration); > > > > } > > > > @WebService(name = "AmIMonitoringService", targetNamespace = " > <http://proseco-project.eu/> http://proseco-project.eu/") > > @SOAPBinding(style = SOAPBinding.Style.DOCUMENT) > > public interface IAmIMonitoringService extends IProsecoService { > > > > @UseAsyncMethod > public String Myping(String par); > > > > public Future<?> MypingAsync(String par, AsyncHandler<MypingResponse> > asyncHandler); > > > > public Response<MypingResponse> MypingAsync(String par); > } > > > > > > public class AmIMonitoringService implements IAmIMonitoringService { > > > > private static final Logger logger = > LoggerFactory.getLogger(AmIMonitoringService.class); > > > > @Override > > public void start() throws ProsecoFault { > > logger.info(String.format("Starting %s ...", > this.getClass().getSimpleName())); > > } > > > > @Override > > public void stop() throws ProsecoFault { > > logger.info(String.format("Stopping %s ...", > this.getClass().getSimpleName())); > > } > > > > @Override > > public void restart() throws ProsecoFault { > > logger.info(String.format("Restarting %s ...", > this.getClass().getSimpleName())); > > } > > > > @Override > > public String ping() throws ProsecoFault { > > logger.info(String.format("%s was pinged", > this.getClass().getSimpleName())); > > return ServiceManager.PING_RESPONSE; > > } > > > > @Override > > public boolean configure(String Configuration) throws ProsecoFault { > > throw new UnsupportedOperationException("Not supported yet."); //To > change body of generated methods, choose Tools | Templates. > > } > > > > @Override > > public Future<?> MypingAsync(final String par, final > AsyncHandler<MypingResponse> asyncHandler) { > > System.out.println("Executing operation changeStudentAsync > asynchronously\n"); > > final ServerAsyncResponse<MypingResponse> asyncResponse = new > ServerAsyncResponse<MypingResponse>(); > > new Thread() { > > @Override > > public void run() { > > try { > > Thread.sleep(10000); > > } catch (InterruptedException e) { > > } > > MypingResponse resp = new MypingResponse(); > > resp.setTestValue("Ola " + par); > > asyncResponse.set(resp); > > System.out.println("Responding on background thread\n"); > > asyncHandler.handleResponse(asyncResponse); > > } > > }.start(); > > > > return asyncResponse; > > } > > > > @Override > > public String Myping(String par) { > > System.out.println("Synchrounous call"); > > return null; > > } > > > > @Override > > public Response<MypingResponse> MypingAsync(String par) { > > return null; > > } > > > > } > > > > - Client code: > > IAmIMonitoringService client = ServiceManager.getWebservice("localhost", > Integer.parseInt("19004"), IAmIMonitoringService.class); > String pong = client.ping(); > TestAsyncHandler handler = new TestAsyncHandler(); > Future<?> response = client.MypingAsync("Giovanni", handler); > while (!response.isDone()) { > Thread.sleep(100); > } > > > > public class TestAsyncHandler implements AsyncHandler<MypingResponse> { > private MypingResponse reply; > @Override > public void handleResponse(Response<MypingResponse> rspns) { > try { > System.err.println("handleResponse called"); > reply = rspns.get(); > } catch (InterruptedException | ExecutionException ex) { > > Logger.getLogger(TestAsyncHandler.class.getName()).log(Level.SEVERE, null, > ex); > } > } > public String getResponse() { > return reply.getTestValue(); > } > } > > > > > The exception that I have when running the following code is: > > > > > > SEVERE: null > java.util.concurrent.ExecutionException: java.lang.ClassCastException: > pt.uninova.proseco.services.jaxws_asm.MypingWebServiceResponse cannot be > cast to pt.uninova.proseco.services.async.response.MypingMessage > at > org.apache.cxf.jaxws.JaxwsClientCallback$2.get(JaxwsClientCallback.java:99) > at > pt.uninova.proseco.services.async.TestAsyncHandler.handleResponse(TestAsyncH > andler.java:27) > at > org.apache.cxf.jaxws.JaxwsClientCallback.handleException(JaxwsClientCallback > .java:87) > at > org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:821) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse > Internal(HTTPConduit.java:1636) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPCond > uit.java:1145) > at > org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl > .java:428) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:11 > 45) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:6 > 15) > at > org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(Autom > aticWorkQueueImpl.java:353) > at java.lang.Thread.run(Thread.java:744) > Caused by: java.lang.ClassCastException: > pt.uninova.proseco.services.jaxws_asm.MypingWebServiceResponse cannot be > cast to pt.uninova.proseco.services.async.response.MypingMessage > at > pt.uninova.proseco.services.async.TestAsyncHandler.handleResponse(TestAsyncH > andler.java:27) > at > org.apache.cxf.jaxws.JaxwsClientCallback.handleResponse(JaxwsClientCallback. > java:44) > at > org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:819) > ... 7 more > Exception in thread "main" java.lang.NullPointerException > at > pt.uninova.proseco.services.async.TestAsyncHandler.getResponse(TestAsyncHand > ler.java:34) > at > pt.uninova.proseco.async.AsyncTestMainClass.main(AsyncTestMainClass.java:51) > > > > > > Basically I have a cast exception here: > public class TestAsyncHandler implements AsyncHandler<MypingResponse> { > private MypingResponse reply; > @Override > public void handleResponse(Response<MypingResponse> rspns) { > try { > > System.err.println("handleResponse called"); > reply = rspns.get(); > } catch (InterruptedException | ExecutionException ex) { > Logger.getLogger(TestAsyncHandler.class.getName()).log(Level.SEVERE, null, > ex); > } > > } > public String getResponse() { > > return reply.getTestValue(); > > } > } > > > > I am using the simplefrontend and the jetty embedded application server for > that reason I don’t have the wsdl since it is automatically generated from > the java code and handled by the environment (I think). Is there any way to > retrieve the wsdl? > > > > BR, > > > > Giovanni > > > > De: Daniel Kulp [via CXF] [mailto:[hidden email]] > Enviada: 7 de janeiro de 2015 22:32 > Para: gido > Assunto: Re: Async Calls > > > > > My suggestion would be to take the generated wsdl from the service and run > the wsdl2java with the -asyncMethods switch on the wsdl and make sure you > either use the generated SEI directly or at least make sure the method > signatures and such directly match what is there. > > Dan > > > > >> On Jan 6, 2015, at 6:41 PM, gido <[hidden email]> wrote: >> >> Dear all, >> >> I have a little problem with the async communication. In particular I am >> trying to implement async calls. My idea is to provide a synchronous > method >> as well as its async implementation. In such a way I can decide which > method >> is suitable for me according to the specific application context. To do >> that, I have followed the Apache CXF documentation and the tutorials: >> >> http://www.javatips.net/blog/2014/03/asynchronous-web-service-using-cxf >> http://www.javatips.net/blog/2014/03/cxf-asynchronous-client >> >> However when I try to call the async method I always receive the following > >> exception: >> >> Exception in thread "main" javax.xml.ws.WebServiceException: Could not > find >> wsdl:binding operation info for web method testAsync. >> at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:126) > >> at com.sun.proxy.$Proxy62.testAsync(Unknown Source) >> at >> > pt.uninova.proseco.async.AsyncTestMainClass.main(AsyncTestMainClass.java:46) > >> >> If I try to call the synch implmentation I have no problem. >> >> I have checked the generated wsdl (I am using the Java first approach) and > I >> see that no async operation is included. >> >> Do you have any sugestion? >> >> BR >> >> Giovanni >> >> >> >> -- >> View this message in context: > http://cxf.547215.n5.nabble.com/Async-Calls-tp5752830.html >> Sent from the cxf-user mailing list archive at Nabble.com. > > > -- > Daniel Kulp > [hidden email] - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com > > > > > _____ > > If you reply to this email, your message will be added to the discussion > below: > > http://cxf.547215.n5.nabble.com/Async-Calls-tp5752830p5752856.html > > To unsubscribe from Async Calls, click here > <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_ > by_code&node=5752830&code=Z2lkb0B1bmlub3ZhLnB0fDU3NTI4MzB8LTQwODEwNTMyNQ==> > . > > <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer > &id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicName > space-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.Node > Namespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_email > s%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> NAML > > > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Async-Calls-tp5752830p5752862.html > Sent from the cxf-user mailing list archive at Nabble.com. -- Daniel Kulp [hidden email] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com _____ If you reply to this email, your message will be added to the discussion below: http://cxf.547215.n5.nabble.com/Async-Calls-tp5752830p5752874.html To unsubscribe from Async Calls, click here <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5752830&code=Z2lkb0B1bmlub3ZhLnB0fDU3NTI4MzB8LTQwODEwNTMyNQ==> . <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> NAML -- View this message in context: http://cxf.547215.n5.nabble.com/Async-Calls-tp5752830p5752967.html Sent from the cxf-user mailing list archive at Nabble.com.
