我使用spring Web服务框架来调用一些SOAP apis。 我的配置是这样的:
<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:读取超时 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。罐子:2.2.4.RELEASE]
可能是什么问题?我很无能
答案 0 :(得分:0)
最后,我不确定是什么问题,但我通过将邮件发件人设置为不同的提供商来解决它。我把它设置为一些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>