I am creating a spring integration outbound gateway with the next configuration:
@Configuration
public class WebServiceConfiguration {
@Bean
@ServiceActivator(inputChannel = "invocationChannel")
public MessageHandler wsOutboundGateway() throws Exception {
MarshallingWebServiceOutboundGateway gw =
new MarshallingWebServiceOutboundGateway(
"http://localhost:8098/mockPort",
jaxb2Marshaller());
gw.setOutputChannelName("responseChannel");
return gw;
}
public Jaxb2Marshaller jaxb2Marshaller() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setProcessExternalEntities(true);
// List of packages with XML Root elements (types) generated with Wsdl2Java
marshaller.setContextPaths(
"com.company.wsdl.types.p1", "com.company.wsdl.types.p2");
}
But I am getting: "Unable to create envelope from given source because the namespace was not recognized" and I hae any idea about this error:
Caused by: com.sun.xml.internal.messaging.saaj.soap.SOAPVersionMismatchException: Unable to create envelope from given source because the namespace was not recognized
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.lookForEnvelope(SOAPPartImpl.java:150)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:121)
at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:110)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:68)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:128)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:189)
UPDATE
I changed my RequestType to the Envelope one and it seems to be recognized but now I am getting: "org.springframework.ws.client.WebServiceTransportException: Internal Server Error [500]".
My server is listening via SOAP UI and it is accessible in the browser.
UPDATE II
Transformer and Handler configuration:
SENDER
@Transformer(inputChannel="requestChannel", outputChannel="invocationChannel")
public ResquestType buildRequest(Message<String> msg) {
//creates a ResquestType from msg param
return ResquestType;
}
RESPONSE HANDLER
@ServiceActivator(inputChannel="responseChannel")
public int getResponse(Message<Envelope> msg) {
// Builds the response status
}
I am sending the structure:
Receiving structure:
"org.springframework.ws.client.WebServiceTransportException: Internal Server Error [500]: Unable to create envelope from given source because the namespace was not recognized
SOAP UI has a feature to trace request/response. Using that you can take a look where you or your service provide bad XML for SOAP.