我试图使用ws:outbound-gateway从spring集成调用web服务(spring-ws)。我使用jaxb2marshaller进行oxm mapping。最初我使用了jms:inbound-channel-adapter来接收输入对象,将其转换为JAXBElement(Sample),其中Sample由JAXB从WS-XSD架构生成。对象工厂用于获取JAXBElement。
执行时,我在客户端(Spring-Integration)收到错误内部服务器错误[500]。在服务端(Spring-WS)抛出,发现无效的字符' - ',期待'>'。相同的服务(Spring-ws)运行良好,并且可以很好地回复Axis-2客户端。所以我假设服务端没有问题,客户端发送的消息(spring-integration)是不合适的。
请告诉我是否有正确的方法,或者我错过了什么
Spring_integration客户端
<int:channel id="wsChainInboundChannel"/>
<int:chain input-channel="wsChainInboundChannel" output-channel="wsInboundChannel">
<int:transformer ref="jms2wsTransform" method="jmsOrderToWSEmployee"/>
</int:chain>
<int:channel id="wsInboundChannel"/>
<int-ws:outbound-gateway id="wsOutboundGateway" request-channel="wsInboundChannel" uri="http://localhost:8081/mywebservice/servicelayer"
marshaller="masterdatajaxb2Marshaller" unmarshaller="masterdatajaxb2Marshaller"
reply-channel="wsOutboundChannel" message-factory="messageFactory"/>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="messageFactory">
<bean class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
</property>
</bean>
<int:channel id="wsOutboundChannel"/>
jms2wsTransform中的jmsOrderToWSEmployee方法是
public class WS2JMSTransformer {
private final ObjectFactory jaxbFactory = new ObjectFactory();
public JAXBElement<TEmployeeBySecurityRequest> jmsOrderToWSEmployee(Message<Order> message){
Order order = message.getPayload();
TEmployeeBySecurityRequest request = new TEmployeeBySecurityRequest();
request.setEmployeeId(order.getOrderQuantity().longValue());
return jaxbFactory.createEmployeeBySecurityRequest(request);
}
}
使用TCP Monitor正常执行的请求SOAP
--MIMEBoundary_57eb271a7b65c0bacefa0a80da1b203d0661422ab29d24a3
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.47eb271a7b65c0bacefa0a80da1b203d0661422ab29d24a3@apache.org>
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<ns1:employeeBySecurity_Request xmlns:ns1="http://com/clickandbuy/mywebservice/">
<ns1:employeeId>12312</ns1:employeeId></ns1:employeeBySecurity_Request></soapenv:Body>
</soapenv:Envelope>
--MIMEBoundary_57eb271a7b65c0bacefa0a80da1b203d0661422ab29d24a3--
使用Spring_integartion客户端SOAP(错误一),
------=_Part_0_157378300.1372091736608
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-
ENV:Header/><SOAP-ENV:Body><ns2:employeeBySecurity_Request
xmlns:ns2="http://com/clickandbuy/mywebservice/"><ns2:employeeId>6</ns2:employeeId>
</ns2:employeeBySecurity_Request></SOAP-ENV:Body></SOAP-ENV:Envelope>
------=_Part_0_157378300.1372091736608--
我观察到了 ?xml version ='1.0'coding ='UTF-8'?&gt; 还有其他一些缺失的东西。有没有办法解决这个问题
由于
答案 0 :(得分:0)
嗨,我终于找到了问题。对于作为JAXB marshaller bean的masterdatajaxb2Marshaller,有一个名为mtomEnabled的属性,在我的配置中用于发送/接收带有SOAP消息的附件是真的。
<property name="mtomEnabled" value="true"/>
如上所述,messageFactory是SaajSoapMessageFactory,它以某种方式导致错误。如果我将消息工厂更改为AxiomSoapMessageFactory,它可以正常工作。
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
</bean>