【问题标题】:Jaxb2Marshaller with Spring Integration与 Spring 集成的 Jaxb2Marshaller
【发布时间】:2015-02-06 16:12:07
【问题描述】:

我正在使用下一个配置创建一个 spring 集成出站网关:

  • invocationChannel 和 responseChannel 的直接通道
  • 一个具有以下配置的请求转换器(在更新 II 中更新)
  • Web 服务网关配置:

@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");

}

但我得到:“无法从给定源创建信封,因为名称空间未被识别”,我对这个错误有任何想法:

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)

更新

我将我的 RequestType 更改为 Envelope 之一,它似乎已被识别,但现在我得到:“org.springframework.ws.client.WebServiceTransportException: Internal Server Error [500]”。

我的服务器正在通过 SOAP UI 进行监听,并且可以在浏览器中访问。

更新 II

Transformer 和 Handler 配置:


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
}

我正在发送结构:

  • 请求类型
  • 信封
  • 标题
  • 身体

接收结构:

  • 信封
  • 标题
  • 身体
  • 响应类型

【问题讨论】:

  • 请显示服务器端的异常。并与marshaller分享您通过wsOutboundGateway发送的实体
  • 服务器端也不例外。我正在查看 SOAP UI 日志。我编辑了我的问题以澄清 SOAP 结构。服务器回复预期的响应。
  • 如果您有 Internal Server Error [500],则应该有其他类似 StackTrace 的东西来确定问题...否则我们无法帮助您
  • 那是我的错,Artem,对不起。我返回到以前的配置(帖子上的当前配置),我的错误是“无法从给定源创建信封,因为无法识别命名空间”而不是错误 500
  • 由于您使用 SOAP UI,因此有一个工具可以监控请求/响应,以确定您是否为请求和响应发送/接收正确的 XML。

标签: spring web-services marshalling spring-integration jaxb2


【解决方案1】:

“org.springframework.ws.client.WebServiceTransportException:内部服务器错误[500]:无法从给定源创建信封,因为名称空间未被识别

SOAP UI 具有跟踪请求/响应的功能。使用它,您可以查看您或您的服务在哪里为 SOAP 提供了错误的 XML。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 2016-05-08
    • 2015-10-27
    相关资源
    最近更新 更多