English 中文(简体)
利用春天客户建立持续的联系
原标题:Making persistent connections using spring-ws client

I am using a spring-ws client to invoke a web service in two way ssl mode. I need to make sure that I don t end up creating a new connection everytime - instead I re-use connections. I did some re-search and found that by default HTTP 1.1 always makes persistent http(s) connections. Is that true?

Do I need any piece of code in my client to ensure connections are persistent? How can I check if the connections are persistent or if a new connection is being created vereytime I send a new request ?

<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">   

    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>   
    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">   
        <constructor-arg ref="messageFactory"/>   
        <property name="marshaller" ref="jaxb2Marshaller" />   
        <property name="unmarshaller" ref="jaxb2Marshaller" />   
        <property name="messageSender" ref="httpSender" />   
    </bean>   

    <bean id="httpSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender">   
    </bean>   

    <oxm:jaxb2-marshaller id="jaxb2Marshaller" contextPath="com.nordstrom.direct.oms.webservices.addressval" />   

    <bean id="Client" class="test.ClientStub">   
          <property name="webServiceTemplate" ref="webServiceTemplate" />    
   </bean>   
</beans>
问题回答

HTTP/1.1有不间断的连接,但服务器可在若干要求后决定关闭,或者不支持保持接触。

检查最容易的方法是使用 t或丝网,检查海关的国旗。 这带来了新的联系。

我正在使用以下文字,在J2SE 1.6上,它没有在多个请求中制造任何新的袖珍。 服务器没有发送连接线:保持-Alive头盔,但连接却一直保持。

Bean configuration:

<bean id="wsHttpClient" factory-bean="customHttpClient"
    factory-method="getHttpClient" />


 <bean id="messageSender"
        class="org.springframework.ws.transport.http.CommonsHttpMessageSender"
        p:httpClient-ref="wsHttpClient" />

http://www.ohchr.org。

import org.apache.commons.httpclient.*;

import org.springframework.stereotype.*;

@Component public class CustomHttpClient {

    private final HttpClient httpClient;

    public CustomHttpClient() {
        httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
        httpClient.getParams().setParameter("http.protocol.content-charset",
            "UTF-8");
        httpClient.getHttpConnectionManager().getParams()
            .setConnectionTimeout(60000);
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(60000);
        httpClient.setHostConfiguration(new HostConfiguration());
    }

    public HttpClient getHttpClient() {
        return httpClient;
    }
}




相关问题
How should I use https in Ruby on Rails

I m developing an application in Rails (2.3.4) and there are some parts that need to run over a secure protocol, for example, the login form, the credit card form, etc. How can I do just these pages ...

How to open a stream to httpS URL

I want to open a stream to a httpS URL and read the data. Kindly let me know how to do it. Regards Chaitanya

direct http to https on certain pages?

Hi I have added the below code to .ht access but how can I add another page to this? such as login.php also if the user types in www. they get a "untrusted connection" as the SSL is only valid ...

See what content is not sent over HTTPS

I created a page that is HTTPS only. On my browsers, I always get a warning that the page includes resources that are not secured. I just can t find out why! Looking at the source code seems fine. All ...

C# maintaining session over HTTPS on the client

I need to login to a website and perform an action. The website is REST based so I can easily login by doing this (the login info is included as a querystring on the URL, so I dont t need to set the ...

热门标签