【发布时间】:2015-08-26 00:05:22
【问题描述】:
我已经部署了一个简单的 JAX-WS 服务,它首先构建了合同。在 JAX-WS Endpoint 配置中,我指定了原始 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 提供的 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/*");
}
}
【问题讨论】:
标签: java web-services wsdl cxf jax-ws