CXF发布webservice入门


一、设置CXF的bin目录进环境变量java

二、CXF导入相关的jar包。web


三、创建接口 ide

 

@WebService
public interface HelloWorld {
	public void say(String name);
}

 

四、实现接口测试

 

@WebService(endpointInterface="com.webservice.HelloWorld",serviceName="HelloWorldWs")
public class HelloWorldImpl implements HelloWorld {
	@Override
	public void say(String name) {
		System.out.println("hello"+name);
	}
}

五、 发布webservicespa

 

 

public class ServiceMain {
	public static void main(String[] args) {
		HelloWorld hw = new HelloWorldImpl();
		Endpoint.publish("http://本地ip地址:端口/HelloWorldWs", hw);//发布helloworld
	}
}

六、测试code

 

http://本地地址:端口/HelloWorldWs?wsdl
xml

出现wsdl相关xml文件便可接口


出错:ip

一、端口可能被占用get

解决:使用其余端口

二、 java.lang.ClassCastException: com.ctc.wstx.stax.WstxInputFactory incompatible with javax.xml.stream.

解决:

出现缺失jar包, http://www.findjar.com进去查找相关jar包,发现缺失wstx-asl-*.jar这个jar包
导入进去便可。(我使用的是 wstx-asl-3.0.0.jar)
相关文章
相关标签/搜索