我很难通过Spring-ws WebServiceTemplate调用SOAP 1.2 WebService.正在进行的请求缺少Http Header中的SOAPAction,并且服务器抛出错误"无法处理没有有效操作参数的请求.请提供有效的soap操作." 通过wireshark监控,我能够发现SOAP Action丢失了.我也不支持任何代理.
通过TCP Mon(像SOAP UI这样的工具)运行请求,我确保我尝试发送的SOAP XML是有效的,并且能够获得响应.
这是我的春季配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" />
</property>
</bean>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="defaultUri" value="https://ecomapi.networksolutions.com/soapservice.asmx" />
<property name="messageSender">
<bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender" /> </property>
</bean>
Run Code Online (Sandbox Code Playgroud)
这是我的java代码:
public void simpleSendAndReceive() {
try{
StreamSource source = new StreamSource(new StringReader(MESSAGE));
StreamResult result = new StreamResult(System.out);
SoapActionCallback actionCallBack = new SoapActionCallback("https://ecomapi.networksolutions.com/soapservice.asmx") {
public void doWithMessage(WebServiceMessage msg) {
SoapMessage …
Run Code Online (Sandbox Code Playgroud)