Jaxb2Marshaller with Spring Integration

I am creating a spring integration outbound gateway with the following configuration:

  • Direct channels for calling Channel and responseChannel
  • One transformer request with the following configuration (updated in update II)
  • Web service gateway 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 get: "Unable to create envelope from given source because namespace was not recognized" and I have an idea of ​​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 Envelope and it seems to have been recognized, but now I get: "org.springframework.ws.client.WebServiceTransportException: Internal Server Error [500]".

My server is listening through a SOAP interface and is available 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 posting the structure:

  • RequestType
  • The envelope
  • Title
  • Body

Reception structure:

  • The envelope
  • Title
  • Body
  • ResponseType
+3


source to share


1 answer


"org.springframework.ws.client.WebServiceTransportException: Internal Server Error [500]: Unable to create envelope from the given source because the namespace was not recognized



The SOAP interface has a request / response tracking feature. Using this, you can take a look at where you or your service is providing bad XML for SOAP.

0


source







All Articles