您的位置:首页 > 其它

简单CXF操作(一)

2016-01-21 15:41 253 查看
服务器端

接口

package test.cxf.server;

import javax.jws.WebService;

@WebService
public interface HelloCXF {
public String say(String name);
}
实现
package test.cxf.server;

import javax.jws.WebService;

@WebService(endpointInterface="test.cxf.server.HelloCXF")
public class HelloCXFImpl implements HelloCXF {

public String say(String name) {
String str="hello,"+name+",this is my first cxf!";
return str;
}

}
发布
package test.cxf.server;

import javax.xml.ws.Endpoint;

public class ServerMain {
public static void main(String[] args) {
HelloCXFImpl implementor = new HelloCXFImpl();
String address = "http://localhost:8080/hellocxf";
Endpoint.publish(address, implementor);
System.out.println("started");
}
}

命令:wsdl2java -client -p test.cxf.client -d e:/ http://localhost:8080/hellocxf?wsdl
生成客户端,放到项目里,运行xxxx_Client.java,可看到运行结果

生成的客户端的java文件:



所用jar包

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: