Spring集成ws:出站网关jaxb内部服务器错误[500]



我正在尝试使用ws:outbound gateway调用来自spring集成的Web服务(spring-ws)。我使用jaxb2marshaller进行oxm映射。最初,我使用jms:inbound通道适配器来接收输入对象,并将其转换为JAXBElement(Sample),其中Sample由JAXB从WS-XSD模式生成。对象工厂用于获取JAXBElement。

执行时,我在客户端(Spring Integration)收到错误Internal Server错误[500]。而在服务端(Spring WS)是throws,Found的字符为"-",应为">"。同样的服务(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版本="1.0"编码="UTF-8"?>几乎没有遗漏其他东西。有没有办法解决这个

感谢

嗨,我终于找到问题了。对于masterdatajaxb2Marshaller,它是一个JAXB marshaller bean,有一个名为mtomEnabled的属性,在我的配置中,它适用于发送/接收带有SOAP消息的附件。

<property name="mtomEnabled" value="true"/>

如上所述,messageFactory是SaajSoapMessageFactory,它以某种方式导致了错误。如果我将消息工厂更改为AxiomSoapMessageFactory,它可以正常工作。

<bean id="messageFactory"  class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
</bean>

最新更新