Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2DD1817C0F for ; Thu, 8 Jan 2015 13:03:25 +0000 (UTC) Received: (qmail 80743 invoked by uid 500); 8 Jan 2015 13:03:25 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 80678 invoked by uid 500); 8 Jan 2015 13:03:25 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 80647 invoked by uid 99); 8 Jan 2015 13:03:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2015 13:03:24 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andreclima.pt@gmail.com designates 209.85.216.169 as permitted sender) Received: from [209.85.216.169] (HELO mail-qc0-f169.google.com) (209.85.216.169) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2015 13:03:20 +0000 Received: by mail-qc0-f169.google.com with SMTP id w7so1687341qcr.0 for ; Thu, 08 Jan 2015 05:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=lMI5p0HDmq+Zrp8y4ngzRG/yZJAbSCq0bWQ5ByXowP4=; b=uYLqewD5YRCqbBNQ+2odVKSaX8TQsWW7uMBhbiJ2cHuceJjK/7C+j+wB97GaJyv+qa /GfCLW69PBZvVrVdakjZDd8gCHExGaEOuAJo42PrGDD6Zn2uioyqAwoWmZf2Y3ZnlNXv 2cOSklS2iBOrKa3Q6WYnBHN9epg4/McI+zKURSJp4fD7H+UT5v3lvvg4MNdizCljqp37 ahqghoC0bbm3zbsrriAmrdHheYuO+IndD5HRta+fnyQXQFlZSxjXvM9M18b6y2h+8J4D leQcxKFsYCp84vKXEan8WQgGtZuR1trdQ44TFpmSispVhxJd1k6MdnWrFvS3lAN/YVGQ 6H3w== X-Received: by 10.224.66.200 with SMTP id o8mr15433930qai.13.1420722179188; Thu, 08 Jan 2015 05:02:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.96.54.3 with HTTP; Thu, 8 Jan 2015 05:02:28 -0800 (PST) Reply-To: andreclima.pt@gmail.com In-Reply-To: <004701d02b3c$117e33e0$347a9ba0$@uninova.pt> References: <1420587710980-5752830.post@n5.nabble.com> <004701d02b3c$117e33e0$347a9ba0$@uninova.pt> From: =?UTF-8?Q?Andr=C3=A9_Costa_Lima?= Date: Thu, 8 Jan 2015 13:02:28 +0000 Message-ID: Subject: Re: Async Calls To: users@cxf.apache.org Content-Type: multipart/alternative; boundary=001a11c2beb0d0b008050c23a8a4 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2beb0d0b008050c23a8a4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The asynchronous implementation is only called if you annotate your synchronous method with @UseAsyncMethod in the implementation. Do not use it in the interface. There is an example here . You can generate the wsdl with java2ws or generate the SEI from a wsdl with wsdl2java . Take a look at the samples that are distributed with CXF. There is at least one example for your use case. Andr=C3=A9 Costa Lima 2015-01-08 12:10 GMT+00:00 gido : > Hi Daniel, > > > > I have also spoken with Andr=C3=A9 Costa Lima (via CXF). I can send you s= ome > other info. > > This is the code that I am going to test: > > > > @WebService > > @SOAPBinding(style =3D SOAPBinding.Style.DOCUMENT) > > public interface IProsecoService { > @WebMethod(operationName =3D "startWebService") > > public void start(); > > @WebMethod(operationName =3D "stopWebService") > public void stop(); > > > > @WebMethod(operationName =3D "restartWebService") > public void restart(); > > > > @WebMethod(operationName =3D "pingWebService") > public String ping(); > > > > @WebMethod(operationName =3D "invokeWebService") > public boolean configure(String Configuration); > > > > } > > > > @WebService(name =3D "AmIMonitoringService", targetNamespace =3D " > http://proseco-project.eu/") > > @SOAPBinding(style =3D SOAPBinding.Style.DOCUMENT) > > public interface IAmIMonitoringService extends IProsecoService { > > > > @UseAsyncMethod > public String Myping(String par); > > > > public Future MypingAsync(String par, AsyncHandler > asyncHandler); > > > > public Response MypingAsync(String par); > } > > > > > > public class AmIMonitoringService implements IAmIMonitoringService { > > > > private static final Logger logger =3D > 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 asyncHandler) { > > System.out.println("Executing operation changeStudentAsync > asynchronously\n"); > > final ServerAsyncResponse asyncResponse =3D new > ServerAsyncResponse(); > > new Thread() { > > @Override > > public void run() { > > try { > > Thread.sleep(10000); > > } catch (InterruptedException e) { > > } > > MypingResponse resp =3D 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 MypingAsync(String par) { > > return null; > > } > > > > } > > > > - Client code: > > IAmIMonitoringService client =3D ServiceManager.getWebservice("localhost= ", > Integer.parseInt("19004"), IAmIMonitoringService.class); > String pong =3D client.ping(); > TestAsyncHandler handler =3D new TestAsyncHandler(); > Future response =3D client.MypingAsync("Giovanni", handler); > while (!response.isDone()) { > Thread.sleep(100); > } > > > > public class TestAsyncHandler implements AsyncHandler { > private MypingResponse reply; > @Override > public void handleResponse(Response rspns) { > try { > System.err.println("handleResponse called"); > reply =3D 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:9= 9) > at > > pt.uninova.proseco.services.async.TestAsyncHandler.handleResponse(TestAsy= ncH > andler.java:27) > at > > org.apache.cxf.jaxws.JaxwsClientCallback.handleException(JaxwsClientCallb= ack > .java:87) > at > org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:821) > at > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespo= nse > Internal(HTTPConduit.java:1636) > at > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPC= ond > uit.java:1145) > at > > org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueI= mpl > .java:428) > at > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java= :11 > 45) > at > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.jav= a:6 > 15) > at > > org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(Au= tom > 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(TestAsy= ncH > andler.java:27) > at > > org.apache.cxf.jaxws.JaxwsClientCallback.handleResponse(JaxwsClientCallba= ck. > 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(TestAsyncH= and > 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 { > private MypingResponse reply; > @Override > public void handleResponse(Response rspns) { > try { > > System.err.println("handleResponse called"); > reply =3D 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 f= or > that reason I don=E2=80=99t have the wsdl since it is automatically gener= ated 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:ml-node+s547215n5752856h18@n5.nabble.co= m > ] > 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 ru= n > 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 a= m > > 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=3Dunsubscr= ibe_ > by_code&node=3D5752830&code=3DZ2lkb0B1bmlub3ZhLnB0fDU3NTI4MzB8LTQwODEwNTM= yNQ=3D=3D > > > > . > > < > http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=3Dmacro_vi= ewer > > &id=3Dinstant_html%21nabble%3Aemail.naml&base=3Dnabble.naml.namespaces.Ba= sicName > > space-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.N= ode > > Namespace&breadcrumbs=3Dnotify_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. > --001a11c2beb0d0b008050c23a8a4--