webservice_cxf的配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了webservice_cxf的配置相关的知识,希望对你有一定的参考价值。
先定义一个接口
import javax.jws.WebService; @WebService public interface HelloWorld { public void sayhi(); }
实现它
import javax.jws.WebService; @WebService(endpointInterface="webservice_cxf.HelloWorld",serviceName="HelloWorld") public class HelloWorldImpl implements HelloWorld{ public void sayhi() { System.out.println("hello world"); } }
发布它
import javax.xml.ws.Endpoint;
public class Public {
public static void main(String[] args) {
System.out.println("web service start");
HelloWorld implementor = new HelloWorldImpl();
String address = "http://localhost:8080/helloWorld";
Endpoint.publish(address, implementor);
System.out.println("+++web service started");
}
}
测试它
public class Client { public static void main(String[] args) { JaxWsProxyFactoryBean jwpfb = new JaxWsProxyFactoryBean(); jwpfb.setServiceClass(HelloWorld.class); jwpfb.setAddress("http://localhost:8080/helloWorld"); HelloWorld hw = (HelloWorld) jwpfb.create(); hw.sayhi(); } }
以上是关于webservice_cxf的配置的主要内容,如果未能解决你的问题,请参考以下文章