我使用Apache和Camel Cxf组件进行for服务。我有4-5 JAX-WS网络服务。我想用Endpoint.publish发布这些网络服务。我目前正在做的是在状态上发布这些服务,例如在WebApplicationContextInitializer中。有谁能指导我在服务器启动时发布这些服务的最好和更合适的方法是什么?注:我不想发表我在互联网上看到的例子。
public static void main() {
HelloWorldImpl implementor = new HelloWorldImpl();
String address = "http://localhost:9000/helloWorld";
Endpoint.publish(address, implementor);
}
我不想做以上的事情来发布网络服务。
发布于 2014-11-14 21:04:45
根据您的问题,我想您没有使用Spring。通常,您会将CXF web服务配置为Spring上下文的一部分。因此,您需要使用CXF传输,然后在扩展CXF类CXFNonSpringServlet的类中发布端点。在该类中,您需要编写类似于以下代码的代码来发布端点:
@Override
public void loadBus(ServletConfig servletConfig) throws ServletException {
super.loadBus(servletConfig);
// You could add the endpoint publish codes here
Bus bus = cxf.getBus();
BusFactory.setDefaultBus(bus);
Endpoint.publish("/Greeter", new GreeterImpl());
// You can als use the simple frontend API to do this
ServerFactoryBean factory = new ServerFactoryBean();
factory.setBus(bus);
factory.setServiceClass(GreeterImpl.class);
factory.setAddress("/Greeter");
factory.create();
}
我从CXF网站上的以下链接中检索到这个链接:
http://cxf.apache.org/docs/servlet-transport.html
https://stackoverflow.com/questions/26936150
复制相似问题