You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by sandeep wadhwa <wa...@gmail.com> on 2013/05/23 12:27:48 UTC

Setting timeout for Service.create() - Already a thread present

Hi,

Few years back there was a problem mentioned in Apache CXF forums:

Is there any way to set a timeout for javax.xml.ws.Service.create().
What happens if the operation to retrieve the WSDL from a remote URL
takes forever?

Could you please explain how to resolve or if there is a different way
to make web service call using CXF client?


Thanks

Sandeep Wadhwa

Re: Setting timeout for Service.create() - Already a thread present

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

You can have a spring file which have http:conduit configuration and build CXF bus from this spring file.

Or using code, you can write your own HTTPConduitConfigurer and register to the default cxf bus, some code should be like 

public class MyHTTPConduitConfigurer implements HTTPConduitConfigurer { 
     public void configure(String name, String address, HTTPConduit c) { 

          HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

         httpClientPolicy.setConnectionTimeout(36000);
         httpClientPolicy.setAllowChunking(false);
         httpClientPolicy.setReceiveTimeout(32000);
         c.setClient(httpClientPolicy);
     } 
} 


MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); 
bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); 
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

www.camelone.org : The open source integration conference: 

On 2013-5-23, at 下午8:33, sandeep wadhwa wrote:

> Hello Freeman-San
> 
> Thanks for your efforts. I have gone through the link. The code is as
> follows:
> 
>  URL wsdl = getClass().getResource("wsdl/greeting.wsdl");
>  SOAPService service = new SOAPService(wsdl, serviceName);
>  Greeter greeter = service.getPort(portName, Greeter.class);
> 
>  // Okay, are you sick of configuration files ?  // This will show
> you how to configure the http conduit dynamically  Client client =
> ClientProxy.getClient(greeter);
>  HTTPConduit http = (HTTPConduit) client.getConduit();
> 
>  HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
> 
>  httpClientPolicy.setConnectionTimeout(36000);
>  httpClientPolicy.setAllowChunking(false);
>  httpClientPolicy.setReceiveTimeout(32000);
> 
> 
> I have a question regarding this. The following code executes before
> HttpConduit comes into picture and this is causing the actual problem.
> 
> SOAPService service = new SOAPService(wsdl, serviceName);
> 
> 
> So will be it Ok even if we write  HttpConduit after the constructor
> call which is taking
> 
> huge time in my case as we are trying to call the actual Webservice
> url & not the local one.
> 
> 
> Cheers
> 
> Sandeep Wadhwa
> 
> Architect - CSC India Pvt. Ltd.
> 
> 
> 
> On Thu, May 23, 2013 at 4:23 PM, Freeman Fang <fr...@gmail.com>wrote:
> 
>> Hi,
>> 
>> I believe now we also use http:conduit to retrieve the remote wsdl, so the
>> http:conduit timeout configuration should also work here, take a look at
>> [1] to get more details
>> 
>> [1]
>> http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html
>> -------------
>> Freeman(Yue) Fang
>> 
>> Red Hat, Inc.
>> FuseSource is now part of Red Hat
>> Web: http://fusesource.com | http://www.redhat.com/
>> Twitter: freemanfang
>> Blog: http://freemanfang.blogspot.com
>> http://blog.sina.com.cn/u/1473905042
>> weibo: @Freeman小屋
>> 
>> www.camelone.org : The open source integration conference:
>> 
>> On 2013-5-23, at 下午6:27, sandeep wadhwa wrote:
>> 
>>> Hi,
>>> 
>>> Few years back there was a problem mentioned in Apache CXF forums:
>>> 
>>> Is there any way to set a timeout for javax.xml.ws.Service.create().
>>> What happens if the operation to retrieve the WSDL from a remote URL
>>> takes forever?
>>> 
>>> Could you please explain how to resolve or if there is a different way
>>> to make web service call using CXF client?
>>> 
>>> 
>>> Thanks
>>> 
>>> Sandeep Wadhwa
>> 
>> 


Re: Setting timeout for Service.create() - Already a thread present

Posted by sandeep wadhwa <wa...@gmail.com>.
Hello Freeman-San

Thanks for your efforts. I have gone through the link. The code is as
follows:

  URL wsdl = getClass().getResource("wsdl/greeting.wsdl");
  SOAPService service = new SOAPService(wsdl, serviceName);
  Greeter greeter = service.getPort(portName, Greeter.class);

  // Okay, are you sick of configuration files ?  // This will show
you how to configure the http conduit dynamically  Client client =
ClientProxy.getClient(greeter);
  HTTPConduit http = (HTTPConduit) client.getConduit();

  HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

  httpClientPolicy.setConnectionTimeout(36000);
  httpClientPolicy.setAllowChunking(false);
  httpClientPolicy.setReceiveTimeout(32000);


I have a question regarding this. The following code executes before
HttpConduit comes into picture and this is causing the actual problem.

SOAPService service = new SOAPService(wsdl, serviceName);


So will be it Ok even if we write  HttpConduit after the constructor
call which is taking

huge time in my case as we are trying to call the actual Webservice
url & not the local one.


Cheers

Sandeep Wadhwa

Architect - CSC India Pvt. Ltd.



On Thu, May 23, 2013 at 4:23 PM, Freeman Fang <fr...@gmail.com>wrote:

> Hi,
>
> I believe now we also use http:conduit to retrieve the remote wsdl, so the
> http:conduit timeout configuration should also work here, take a look at
> [1] to get more details
>
> [1]
> http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html
> -------------
> Freeman(Yue) Fang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://fusesource.com | http://www.redhat.com/
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
> http://blog.sina.com.cn/u/1473905042
> weibo: @Freeman小屋
>
> www.camelone.org : The open source integration conference:
>
> On 2013-5-23, at 下午6:27, sandeep wadhwa wrote:
>
> > Hi,
> >
> > Few years back there was a problem mentioned in Apache CXF forums:
> >
> > Is there any way to set a timeout for javax.xml.ws.Service.create().
> > What happens if the operation to retrieve the WSDL from a remote URL
> > takes forever?
> >
> > Could you please explain how to resolve or if there is a different way
> > to make web service call using CXF client?
> >
> >
> > Thanks
> >
> > Sandeep Wadhwa
>
>

Re: Setting timeout for Service.create() - Already a thread present

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

I believe now we also use http:conduit to retrieve the remote wsdl, so the http:conduit timeout configuration should also work here, take a look at [1] to get more details

[1]http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

www.camelone.org : The open source integration conference: 

On 2013-5-23, at 下午6:27, sandeep wadhwa wrote:

> Hi,
> 
> Few years back there was a problem mentioned in Apache CXF forums:
> 
> Is there any way to set a timeout for javax.xml.ws.Service.create().
> What happens if the operation to retrieve the WSDL from a remote URL
> takes forever?
> 
> Could you please explain how to resolve or if there is a different way
> to make web service call using CXF client?
> 
> 
> Thanks
> 
> Sandeep Wadhwa