Setting the CXF WebService client timeout length

Source: Internet
Author: User
Tags set time xmlns

When using webservice, we usually set the request timeout limit in the client to avoid long-time connections to unavailable servers. In a CXF environment, the client can configure the time-out limit with two properties: Connectiontimeout-webservice is based on a TCP connection, which can be understood as the time setting of the TCP handshake, which exceeds the set time as a connection timeout. In milliseconds, The default is 30000 milliseconds, or 30 seconds. ReceiveTimeout-This property is the time to wait for a response after sending a WebService request, which is considered to be a response time-out over a set length. In milliseconds, the default is 60000 milliseconds, or 60 seconds.

There are two ways to configure the client:


One, set in the spring configuration file.

<?xml version= "1.0" encoding= "UTF-8"?> <beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:x Si= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:jee= "Http://www.springframework.org/schema/jee" Xmlns:jax Ws= "Http://cxf.apache.org/jaxws" xmlns:http-conf= "Http://cxf.apache.org/transports/http/configuration" xsi:s chemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-2.0.xsd Http://www.springframework.org/schema/jee HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/JEE/SPR Ing-jee-2.0.xsd Http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd HTTP://CXF . apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd ">  

Here are a few places to note:
1, need to specify http-conf namespace: Xmlns:http-conf=http://cxf.apache.org/transports/http/configuration.
2, specify the mode location: Http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd.
3. The Name property in Http-conf:conduit, specifying the service to which the setting is in effect. The Name property consists of the service's namespace, port name in the WSDL, and ". Http-conduit", such as {http://apache.org/hello_world}helloworld.http- Conduit If you set the Name property to "*.http-conduit", all services will be in effect.

Second, through the Java code to set up. Alternatively: The server side can also be set to the spring code as follows: <!--set the response timeout limit on the server side, now using the default value of 30 seconds--
★ For more detailed configuration please refer to CXF official documentation:

Http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.