It is mainly set during client calls:
- When using WebService, we may need a backup WebService server. once the master server is down, we can use the backup server. in this case, you need to modify the connection time of the client to the server.
- In the spring + cxf WebService environment, the client has two configurable Time Attributes: connectiontimeout and receivetimeout.
- Connectiontimeout -- WebService is based on a TCP connection. This attribute can be understood as the time setting for a TCP handshake. If the time exceeds the set length, the connection times out. in milliseconds. The default value is 30000 milliseconds, that is, 30 seconds.
- Receivetimeout -- this attribute is the waiting time for a response after a WebService request is sent. If the response time exceeds the configured length, it is regarded as a response timeout. in milliseconds, the default value is 60000 milliseconds, that is, 60 seconds.
- Example of setting beans. xml:
- <? XMLVersion = "1.0" encoding = "UTF-8"?>
- <BeansXmlns = "http://www.springframework.org/schema/beans"
- Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
- Xmlns: Jee = "http://www.springframework.org/schema/jee"
- Xmlns: jaxws = "http://cxf.apache.org/jaxws"
- Xmlns: http-conf = "http://cxf.apache.org/transports/http/configuration"
- Xsi: schemalocation = "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/spring-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">
- <Http-conf: conducting itName = "{http://impl.service.product.super.com/?projectservice.http-conduit">
- <Http-conf: ClientConnectiontimeout = "10000" receivetimeout = "20000"/>
- </HTTP-conf: conducting it>
- </Beans>
- Note the following points:
- 1: You need to specify the http-conf namespace xmlns: http-conf = http://cxf.apache.org/transports/http/configuration
- 2: Specify mode location: http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
- 3: http-conf: Name attribute in the pipeline, which specifies the service for which the setting takes effect. In this example, only the service with the service name {http://impl.service.product.sw#com/#projectservicetakes effect.
- The following settings will take effect for all services.
- <Http-conf: conducting itName = "*. http-conduit">
<Http-conf: client……>
- </HTTP-conf: conducting it>
- For more detailed configuration, see the official cxf documentation:
- Http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html
'2. code writing:
Private Static VoidRecievetimeoutwrapper (Object O)
{
Conductor it =
(Clientproxy.Getclient(O). getconduit ());
Httpconduit Hc =
(Httpconduit) conduit;
Httpclientpolicy
Client =NewHttpclientpolicy ();
Client. setreceivetimeout (1000*60*5); // 5-minute timeout. This time is the response timeout.
// Client. setconnectiontimeout (1000*45); // The connection times out in 45 seconds.
HC. setclient (client );
}
Recievetimeoutwrapper (o) wraps each service