gpt4 book ai didi

spring - Jaxb2Marshaller 与 Spring 集成

转载 作者:行者123 更新时间:2023-12-02 23:52:03 26 4
gpt4 key购买 nike

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

  • inplicationChannel 和 responseChannel 的直接 channel
  • 一个具有以下配置的请求转换器(在更新 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");

}

但我得到:“无法从给定源创建信封,因为 namespace 无法识别”,我对此错误有任何想法:

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:内部服务器错误 [500]”。

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

更新二

转换器和处理程序配置:

<小时/>
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
}
<小时/>

我正在发送结构:

  • 请求类型
  • 信封
  • 标题
  • 正文

接收结构:

  • 信封
  • 标题
  • 正文
  • 响应类型

最佳答案

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

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

关于spring - Jaxb2Marshaller 与 Spring 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27367592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com