Soap CXF-WS与spring boot的集成(jhipster堆栈)

Soap CXF-WS与spring boot的集成(jhipster堆栈),soap,cxf,jhipster,Soap,Cxf,Jhipster,我尝试将CXF WS集成到jhipster堆栈,因此避免xml配置 配置服务的第一个类 @EnableWs @Configuration @AutoConfigureAfter(WebConfigurer.class) public class WebServiceConfig extends WsConfigurerAdapter { @Bean public ServletRegistrationBean dispatcherServlet() { CXFS

我尝试将CXF WS集成到jhipster堆栈,因此避免xml配置

配置服务的第一个类

@EnableWs
@Configuration
@AutoConfigureAfter(WebConfigurer.class)
public class WebServiceConfig extends WsConfigurerAdapter {

    @Bean
    public ServletRegistrationBean dispatcherServlet() {
        CXFServlet cxfServlet = new CXFServlet();
        return new ServletRegistrationBean(cxfServlet, "/soap/*");
    }

    @Bean(name = "cxf")
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public Hello hello() {
        return new HelloPortImpl();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), hello());
        endpoint.publish("/hello");
        return endpoint;
    }
}
第二个文件:

@WebService(targetNamespace = "http://service.ws.sample/", name = "Hello")
public interface Hello {


    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "sayHello", targetNamespace = "http://service.ws.sample/", className = "com.orange.api.rfid.tacites.proxyauth.web.restWS.SayHello")
    @WebMethod(action = "urn:SayHello")
    @ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://service.ws.sample/", className = "com.orange.api.rfid.tacites.proxyauth.web.restWS.SayHelloResponse")
    public java.lang.String sayHello(
        @WebParam(name = "myname", targetNamespace = "")
        java.lang.String myname
    );
}
第三个文件

@javax.jws.WebService(
    serviceName = "HelloService",
    portName = "HelloPort",
    targetNamespace = "http://service.ws.sample/",
    endpointInterface = "com.orange.api.rfid.tacites.proxyauth.web.restWS.Hello")


public class HelloPortImpl implements Hello {

    private static final Logger LOG = Logger.getLogger(HelloPortImpl.class.getName());

    public java.lang.String sayHello(java.lang.String myname) {
        LOG.info("Executing operation sayHello" + myname);
        try {
            return "Welcome to CXF Spring boot " + myname + "!!!";
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }
}
在启动spring boot时的日志中,我有以下行:

[DEBUG] com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator - Wrigin XML Schema for com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator@6a08fd54[http://service.ws.sample/=com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace@76617add]
com.sun.xml.bind.v2.util.StackRecorder: null
    at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:441) [jaxb-impl-2.2.jar:2.2]
问题是Jhipster index.html找不到,在调用参数未知的未知方法时,我没有绑定操作信息

我认为CXFServlet首先杀死一个servlet,如何配置两者共存


关于

请尝试将您的WebServiceConfig.dispatcherServlet方法重命名为其他方法,因为您正在覆盖的Spring Boot可能有一个具有此名称的bean。

为了解决此问题,我向WebConfigure.java添加了:

/**
 * Initialize cxf - ws
 */
private void initCxf(ServletContext servletContext) {
    log.debug("Initialize cxf - ws");
    ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CxfWS", new CXFServlet());
    cxfServlet.addMapping("/soap/*");
    cxfServlet.setLoadOnStartup(3);
}

我在没有指定正确的wsdl名称时遇到了这个错误。验证Soap服务实例是否使用到wsdl的正确路径。

将CXF与JHipster一起使用的示例:这就是重点!dispatcherServlet使用Spring Boot嵌入式Tomcat覆盖标准映射。如果您将其命名为cxfDispatcherServlet,您应该会很好