【问题标题】:Read time out spring web services读取超时 Spring Web 服务
【发布时间】:2016-04-07 20:45:45
【问题描述】:

我正在使用 Spring Web 服务框架来调用一些 SOAP api。 我的配置是这样的:

<bean name="wsTemplate" class="org.springframework.ws.client.core.WebServiceTemplate" scope="prototype" >
    <constructor-arg ref="messageFactory" />
    <property name="marshaller" ref="marshaller"/>
    <property name="unmarshaller" ref="unmarshaller"/>
</bean>

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="soapVersion">
        <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"/>
    </property>
</bean>

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
    <property name="contextPaths">
        <list>
             some configured classes here
        </list>
    </property>
</bean>
<bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
   <property name="contextPaths">
        <list>
            some configured classes here
        </list>
    </property>
</bean>

注意我使用的是原型范围。我不确定这是否会导致问题。

在我的 java 代码中,我像这样使用 WebServiceTemplate:

@PostConstruct
private void init() {

    try {
        String uri = "https://web/file.svc?wsdl"
        webServiceTemplate.setDefaultUri(uri);            
    } catch (Exception exception) {
        logger.error("Error creating URL for the wsdl location.", exception);
    }

}

我这样调用网络服务:

Response response = (Response) webServiceTemplate.marshalSendAndReceive(request, new SoapActionCallback(SOAP_ACTION_URL));

我收到以下读取超时异常,我不确定它是什么,我读过它是因为响应太大,但实际上不是。不大于100K

org.springframework.ws.client.WebServiceIOException:I/O错误:读取超时;嵌套异常是 java.net.SocketTimeoutException: Read timed out 15:27:49,028 INFO [stdout](默认任务 22)在 org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561) ~[spring-ws-core-2.2.4.RELEASE.罐子:2.2.4.RELEASE] 15:27:49,028 INFO [stdout](默认任务 22)在 org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) ~[spring-ws-core-2.2.4.RELEASE.罐子:2.2.4.RELEASE] 15:27:49,028 INFO [stdout](默认任务 22)在 org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383) ~[spring-ws-core-2.2.4.RELEASE. jar:2.2.4.RELEASE]

可能是什么问题?我一无所知

【问题讨论】:

标签: spring-ws


【解决方案1】:

最后,我不确定是什么问题,但我通过将消息发送者设置为不同的提供者来解决它。我将它设置为一些 apache 库

<bean name="wsTemplate" class="org.springframework.ws.client.core.WebServiceTemplate" scope="prototype" >
    <constructor-arg ref="messageFactory" />
    <property name="marshaller" ref="marshaller"/>
    <property name="unmarshaller" ref="unmarshaller"/>
    <property name="messageSender">
        <bean class="org.springframework.ws.transport.http.HttpComponentsMessageSender" />
    </property>
</bean>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    • 2011-04-24
    • 2014-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    相关资源
    最近更新 更多