You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by nancy <na...@daffodildb.com> on 2006/08/01 07:02:32 UTC

READ TIME OUT using NONBlocking client

Hello,

 

            I want to use callback means nonblocking axis client to call
webservice.I am using following code for that.But even then read time out is
occurring.As my process can take several hours in responding,so I need this
kind of thing.Please help

 

 

****************************************************************************
****************************************************************************
***********

SOAPEnvelope resultEnvelope = null;

                        Options options = null;

                        try {

                                    options = new Options();

 
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

                        

                                    EndpointReference EPR = new
EndpointReference(webServiceURI);

 

                                    log.info("EndpointReference:" +
EPR.getAddress());

                                    options.setTo(EPR);

 

                                    options.setAction(operationName);

 

 

            //Callback to handle the response

            Callback callback = new Callback() {

                public void onComplete(AsyncResult result) {

                try {

                        StringWriter writer = new StringWriter();

 
result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()

                                .createXMLStreamWriter(writer));

                        writer.flush();

                        System.out.println(writer.toString());

 

 

                    } catch (XMLStreamException e) {

                        onError(e);

                    }

                }

 

                public void onError(Exception e) {

                    e.printStackTrace();

                }

            };            

 

                                    ServiceClient serviceClient;

                                    options.setUseSeparateListener(false);

 

                                    serviceClient = new ServiceClient();

                                    serviceClient.setOptions(options);

                                    OMElement
params1=getRequestOMElement(operationName, parameterMap,
"urn:CallWebService");

 
serviceClient.sendReceiveNonblocking(params1, callback);

         

                                    while (!callback.isComplete()) {

                                                Thread.sleep(1000);

                                      }

                        

 

                                       serviceClient.finalizeInvoke();

                                    

                        } catch (AxisFault ex) {

                                    ex.printStackTrace();

                        

                        } catch (InterruptedException ex) {


                                    ex.printStackTrace();


                        }

****************************************************************************
****************************************************************************
***********

 

            

With Warm Regards, 

Nancy Aggarwal 

 

 


 

 


Re: READ TIME OUT using NONBlocking client

Posted by Deepal Jayasinghe <de...@opensource.lk>.
The best option is to use the two transports case.

  opts.setUseSeparateListener(true);

And you need to engage addressing.
      

nancy wrote:

> Hello,
>
>  
>
>             I want to use callback means nonblocking axis client to
> call webservice.I am using following code for that.But even then read
> time out is occurring.As my process can take several hours in
> responding,so I need this kind of thing.Please help
>
>  
>
>  
>
> *******************************************************************************************************************************************************************
>
> SOAPEnvelope resultEnvelope = null;
>
>                         Options options = null;
>
>                         try {
>
>                                     options = new Options();
>
opts.setUseSeparateListener(true);

>                                    
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>
>                        
>
>                                     EndpointReference EPR = new
> EndpointReference(webServiceURI);
>
>  
>
>                                     log.info("EndpointReference:" +
> EPR.getAddress());
>
>                                     options.setTo(EPR);
>
>  
>
>                                     options.setAction(operationName);
>
>  
>
>  
>
>             //Callback to handle the response
>
>             Callback callback = new Callback() {
>
>                 public void onComplete(AsyncResult result) {
>
>                 try {
>
>                         StringWriter writer = new StringWriter();
>
>                        
> result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
>
>                                 .createXMLStreamWriter(writer));
>
>                         writer.flush();
>
>                         System.out.println(writer.toString());
>
>  
>
>  
>
>                     } catch (XMLStreamException e) {
>
>                         onError(e);
>
>                     }
>
>                 }
>
>  
>
>                 public void onError(Exception e) {
>
>                     e.printStackTrace();
>
>                 }
>
>             };           
>
>  
>
>                                     ServiceClient serviceClient;
>
>                                     options.setUseSeparateListener(false);
>
>  
>
>                                     serviceClient = new ServiceClient();
>
>                                     serviceClient.setOptions(options);
>
>                                     OMElement
> params1=getRequestOMElement(operationName, parameterMap,
> "urn:CallWebService");
>
>                                    
> serviceClient.sendReceiveNonblocking(params1, callback);
>
>         
>
>                                     while (!callback.isComplete()) {
>
>                                                 Thread.sleep(1000);
>
>                                       }
>
>                        
>
>  
>
>                                        serviceClient.finalizeInvoke();
>
>                                    
>
>                         } catch (AxisFault ex) {
>
>                                     ex.printStackTrace();
>
>                        
>
>                         } catch (InterruptedException ex)
> {                                  
>
>                                    
> ex.printStackTrace();                             
>
>                         }
>
> *******************************************************************************************************************************************************************
>
>  
>
>            
>
> *With Warm Regards,* **
>
> *Nancy Aggarwal *
>
>  
>
>  
>
>
> ** **
>
>  
>

-- 
Thanks,
Deepal
................................................................
~Future is Open~ 




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: READ TIME OUT using NONBlocking client

Posted by nancy <na...@daffodildb.com>.
Please help somebody. I am facing this problem from very long time.

 

  _____  

From: nancy [mailto:nancy.aggarwal@daffodildb.com] 
Sent: Tuesday, August 01, 2006 10:33 AM
To: axis-user@ws.apache.org
Subject: READ TIME OUT using NONBlocking client

 

Hello,

 

            I want to use callback means nonblocking axis client to call
webservice.I am using following code for that.But even then read time out is
occurring.As my process can take several hours in responding,so I need this
kind of thing.Please help

 

 

****************************************************************************
****************************************************************************
***********

SOAPEnvelope resultEnvelope = null;

                        Options options = null;

                        try {

                                    options = new Options();

 
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

                        

                                    EndpointReference EPR = new
EndpointReference(webServiceURI);

 

                                    log.info("EndpointReference:" +
EPR.getAddress());

                                    options.setTo(EPR);

 

                                    options.setAction(operationName);

 

 

            //Callback to handle the response

            Callback callback = new Callback() {

                public void onComplete(AsyncResult result) {

                try {

                        StringWriter writer = new StringWriter();

 
result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()

                                .createXMLStreamWriter(writer));

                        writer.flush();

                        System.out.println(writer.toString());

 

 

                    } catch (XMLStreamException e) {

                        onError(e);

                    }

                }

 

                public void onError(Exception e) {

                    e.printStackTrace();

                }

            };            

 

                                    ServiceClient serviceClient;

                                    options.setUseSeparateListener(false);

 

                                    serviceClient = new ServiceClient();

                                    serviceClient.setOptions(options);

                                    OMElement
params1=getRequestOMElement(operationName, parameterMap,
"urn:CallWebService");

 
serviceClient.sendReceiveNonblocking(params1, callback);

         

                                    while (!callback.isComplete()) {

                                                Thread.sleep(1000);

                                      }

                        

 

                                       serviceClient.finalizeInvoke();

                                    

                        } catch (AxisFault ex) {

                                    ex.printStackTrace();

                        

                        } catch (InterruptedException ex) {


                                    ex.printStackTrace();


                        }

****************************************************************************
****************************************************************************
***********

 

            

With Warm Regards, 

Nancy Aggarwal