编程语言
首页 > 编程语言> > java-MarshallingWebServiceInboundGateway的问题

java-MarshallingWebServiceInboundGateway的问题

作者:互联网

我正在使用带有spring-integration和spring-ws的spring-boot来提供SOAP Web服务作为集成流程的入口.

我因此配置了入站网关:

@Bean
MarshallingWebServiceInboundGateway entryPoint() {
    MarshallingWebServiceInboundGateway entryPoint = new MarshallingWebServiceInboundGateway(jaxb2Marshaller());
    return entryPoint;
}

@Bean
Jaxb2Marshaller jaxb2Marshaller() {
    Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    jaxb2Marshaller.setContextPath("my.schemas");
    return jaxb2Marshaller;
}

因此,已配置MessageDispatcherServlet:

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext context) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(context);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/entrypoint/*");
}

和映射:

@Autowired
MarshallingWebServiceInboundGateway entryPoint;

@Bean
UriEndpointMapping uriEndpointMapping() {
    UriEndpointMapping uriEndpointMapping = new UriEndpointMapping();
    uriEndpointMapping.setDefaultEndpoint(entryPoint);
    return uriEndpointMapping;
}

根据docs,我应该能够以这种方式使用MarshallingWebServiceInboundGateway,但是当我在SoapUI的此端点上尝试请求时,我得到了:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring xml:lang="en">No adapter for endpoint [entryPoint]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我在这里想念什么?

解决方法:

这个问题解决了.我还必须这样定义一个bean:

@Bean
MessageEndpointAdapter messageEndpointAdapter() {
    MessageEndpointAdapter adapter = new MessageEndpointAdapter();
    return adapter;
}

我在任何文档中都找不到对此的引用,但这为我解决了这个特殊问题.

标签:java,soap,spring-integration
来源: https://codeday.me/bug/20191120/2043260.html