Hi André,

 

Here you can find the SEI and its implementation:

 

@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/";)

@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)

public interface IAmIMonitoringService extends IProsecoService {

 

    @WebMethod(operationName = "MypingWebService")

    public String Myping(String par);

 

    @WebMethod(operationName = "MypingWebService")

    @ResponseWrapper(localName = "MypingResponse", className = 
"pt.uninova.proseco.services.async.response.MypingResponse")

    public Future<?> MypingAsync(String par, AsyncHandler<MypingResponse> 
asyncHandler);

 

}

 

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) {

        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.

    }

 

}

 

-          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();

    }

 

}

 

I hope this can help.

 

BR,

 

Giovanni

 

De: André Costa Lima [via CXF] 
[mailto:[email protected]] 
Enviada: 7 de janeiro de 2015 00:30
Para: gido
Assunto: Re: Async Calls

 

Hi, 

Can you provide the code of your SEI class? 

Thanks. 

André Costa Lima 


2015-01-06 23:41 GMT+00:00 gido <[hidden email]>: 


> 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. 
> 

 

  _____  

If you reply to this email, your message will be added to the discussion below:

http://cxf.547215.n5.nabble.com/Async-Calls-tp5752830p5752832.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-tp5752830p5752839.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to