Reputation: 509
I am trying to invoke, a webservice(spring-ws) from spring integration using ws:outbound-gateway. I have used jaxb2marshaller for oxm mapping. Initially I have used a jms:inbound-channel-adapter, to recieve input object, convert it to JAXBElement(Sample), where in Sample is generated by JAXB from WS-XSD schema. The object factory is used to get JAXBElement.
I am receiving error Internal Server error[500] at client(Spring-Integration) when executed. And on service end(Spring-WS) is throws, Found invalid char '-', expecting '>'. The same service(Spring-ws) works fine and replies well with an Axis-2 client. So I assume there is no issue on service end and the message sent from client(spring-integration) is improper.
Please suggest me if there is a proper way of doing this, or am I missing something
Spring_integration client
<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"/>
jmsOrderToWSEmployee method in jms2wsTransform is
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);
}
}
With TCP Monitor normal well executed request SOAP is
--MIMEBoundary_57eb271a7b65c0bacefa0a80da1b203d0661422ab29d24a3
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<?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--
And with Spring_integartion client SOAP(error one) is,
------=_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--
I observe that ?xml version='1.0' encoding='UTF-8'?> and few other things missing. Is there some way to resolve this
Thanks
Upvotes: 0
Views: 3498
Reputation: 509
Hi at last I could find the problem. For masterdatajaxb2Marshaller which is a JAXB marshaller bean there is a property called mtomEnabled which was true in my configuration for sending/receiving attachments with SOAP messages.
<property name="mtomEnabled" value="true"/>
And as above the messageFactory is SaajSoapMessageFactory, which somehow was causing error. If i change the message factory to AxiomSoapMessageFactory it works fine.
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
</bean>
Upvotes: 1