开发需要的jar包:
服务器端代码:
package com.cxf.ws.service;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
public String sayHello(String name);
}
package com.cxf.ws.service.impl;
import javax.jws.WebService;
import com.cxf.ws.service.HelloWorld;
@WebService(endpointInterface="com.cxf.ws.service.HelloWorld",serviceName="HelloWorldImpl")
public class HelloWorldImpl implements HelloWorld{
@Override
public String sayHello(String name) {
return "hello,"+name+"!";
}
}
package com.cxf.ws.app;
import javax.xml.ws.Endpoint;
import com.cxf.ws.service.HelloWorld;
import com.cxf.ws.service.impl.HelloWorldImpl;
public class Server {
public static void main(String[] args) {
// JaxWsServerFactoryBean factoryBean=new JaxWsServerFactoryBean();
// factoryBean.setAddress("http://192.168.0.251:9999/CXF-WS-Server");
// factoryBean.setServiceClass(HelloWorld.class);
// factoryBean.setServiceBean(new HelloWorldImpl());
// factoryBean.create();
HelloWorld hw=new HelloWorldImpl();
Endpoint.publish("http://192.168.0.251:9999/CXF-WS-Server", hw);
System.out.println("发布成功!");
}
}
配置wsdl2java环境:
path:D:\apache-cxf-2.5.8\bin
cmd 命令:
切换目录到客户端工程的src下
wsdl2java http://192.168.0.251:9999/CXF-WS-Server/HelloWorld?wsdl
客户端代码:
package com.cxf.ws.app;
import com.cxf.ws.service.HelloWorld;
import com.cxf.ws.service.impl.HelloWorldImpl;
public class Client {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
HelloWorldImpl fac=new HelloWorldImpl();
HelloWorld hw=fac.getHelloWorldImplPort();
String word=hw.sayHello("金聪敏");
System.out.println(word);
}
}
- 大小: 29.2 KB
分享到:
相关推荐
cxf开发webservice客户端和服务器端,详细的cxf使用指令,有用的示例代码及注释。
springmvc+mybatis+cxf+客户端+服务器端+soap+rest方式+内部有数据库
SpringBoot基础框架,集成了通过CXF发布WebService技术,包括服务器端和客户端,直接可运行
java CXF客户端请求ERP SAP webservice通过用户名和密码验证功能!
Android调用WebService的例子(包括服务器端和客户端)。服务器端使用CXF框架发布,Android客户端使用KSOAP2包读取数据。 分别提供了JavaBean、XML、JSON数据类型的通信方式。
使用cxf生成webservice,包括客户端和服务器端,非常好用
作为一个刚学java,被抓壮丁的写服务器端的妹子,我只想说,画了我3周才解决了所有的错误啊,真的要自己因为不懂乱写乱改的时候遇到的那些莫名其妙的错误,因此对android客户端的好感上升了不止一个Level啊....
教你怎么用CXF编写WebService 的服务器端和客户端的视频和源码。
里面有数据库,java版本
webservice cxf 里面的分为2部分 服务器端项目 客户端demo 测试个各种传递参数的test类 适合初学者 情况readme txt
08.CXF拦截器的理论以及如何为CXF的客户端和服务器端添加拦截器
使用CXF开发Web Service,包含服务器端和客户端
Apache Cxf WebService整合Spring 处理Map、非javabean式的复合类等CXF无法自动转化的类型 CXF为服务器端和客户端添加自定义拦截器进行权限检查验证并且控制台打印日志
资源名称:疯狂软件李刚WebService视频教程(15集)资源目录:【】01.WebService概述和WebService在企业应用中的作用【】02.CXF功能概述_CXF发展历史和使用CXF开发WebService服务器端【】03.使用CXF开发WebService...
该项目主要是基于cxf的webservice开发。包括客户端,服务器端的相关代码,同时还包括需要的工具。
cxf用于开发webservice客户端及服务器端,根据wsdl可以直接使用
1、服务器端 Ⅰ)开发web service业务接口,该接口用@WebService修饰; Ⅱ)开发web service业务接口的实现类,也要用@WebService修饰; Ⅲ)使用EndPoint类的静态方法publish()来发布web service。 2、客户端 ...
Webservice服务器端跟客户端创建时所需要用到的jar包资源