簡體   English   中英

通過CXF的JAX-WS WebService提供了不正確的wsdl

[英]JAX-WS WebService via CXF provides inaccurate wsdl

我已經部署了一個簡單的JAX-WS服務,首先建立合同。 在JAX-WS端點配置中,我指定原始wsdl的位置。 但是,這不是cxf返回的wsdl。 原始的wsdl包含策略聲明,該策略聲明是合同的重要組成部分,並且應該在wsdl中對服務使用者可見。

我知道我在端點上設置的wsdl位置是正確的。 如果不正確,戰爭的部署將失敗。 我還記錄了該值以進行仔細檢查。

在本地部署時,該服務位於http:// localhost:8080 / store-web-0.1.0 / services / store

問題 :可從http:// localhost:8080 / store-web-0.1.0 / services / store?wsdl獲得的wsdl不包含可以在原始wsdl中看到的策略語句。 忽略合同的這一重要部分是不可接受的。

問題 :為什么在http:// localhost:8080 / store-web-0.1.0 / services / store上的wsdl缺少策略語句,而不僅僅是在jax-ws端點上配置的原始wsdl,所以缺少策略語句?

其他詳細信息如下。 如果您想查看其他信息,請告訴我。

提前致謝!


細節

我們使用的是:JBoss EAP 6.2,CXF 2.7.16(不選擇移動到CXF 3.x),Spring 4.1.6

我們在jboss-deployment-descriptor.xml文件中排除了“ webservices”子系統

JAX-WS配置類

@Bean StoreImpl storeImpl() {
    return new StoreImpl();
}

@Bean
public Endpoint storeServiceEndpoint() {
    EndpointImpl endpoint = new EndpointImpl(storeImpl());
    endpoint.publish("/store");

    // This configuration is located in the WAR, but WSDL is in separate JAR
    String wsdlLocation = this.getClass().getResource("/store.wsdl").toString();

    endpoint.setWsdlLocation(wsdlLocation);
    return endpoint;
}

Web服務實現類

@WebService(endpointInterface = "my.service.Store", serviceName = "store")
public class StoreImpl implements Store {

    public StoreImpl() {
    }

    @Override
    public BuySomethingResponse buySomething(BuySomethingRequest buySomethingRequest) {

        // operation implementation code here

        return response;
    }

}

Web應用程序初始化

@Order(value=1)
public class StoreWebInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext container) throws ServletException {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(JAXWSEndpointConfig.class);

        container.addListener(new ContextLoaderListener(context));  
    }
}

@Order(value=2)
public class CXFWebInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext container) throws ServletException {
        ServletRegistration.Dynamic dispatcher = container.addServlet("CXFServlet", CXFServlet.class);  
       dispatcher.addMapping("/services/*");
   }
}

我發現了3個問題。

問題#1從問題中包含的JAX-WS配置類代碼中可以看出,我發布端點設置了wsdl位置。

問題#2和#3 StoreImpl類上的@WebService批注需要另外兩個屬性集: targetNamespaceportName 顯然,它們的值必須與原始WSDL中定義的值匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM