5.开发webservice
package com.atguigu.ws; import javax.jws.WebMethod;
import javax.jws.WebService; /**
*
* @author Administrator
*
*/
@WebService
public interface HelloWS { @WebMethod
public String sayHello(String name);
}
package com.atguigu.ws.impl; import javax.jws.WebService; import com.atguigu.ws.HelloWS; @WebService
public class HelloWSImpl implements HelloWS { @Override
public String sayHello(String name) {
System.out.println("server sayHello() "+name); return "Hello "+name;
} }
package com.atguigu.server; import javax.xml.ws.Endpoint; import com.atguigu.ws.impl.HelloWSImpl; /**
* 发布webservice
* @author Administrator
*
*/
public class ServerTest { public static void main(String[] args) {
String address = "http://192.168.0.114:8989/day01_ws/hellows";
//Endpoint发布
Endpoint.publish(address, new HelloWSImpl());
System.out.println("发布webservice成功");
}
}
1).打开cmd工具窗口,进入客户端src目录(可拖拽进入)执行wsimport -keep url命令,进入eclipse刷新客户端src目录
package com.atguigu.ws.client.test; import com.atguigu.ws.impl.HelloWSImpl;
import com.atguigu.ws.impl.HelloWSImplService; /**
* 调用webservice
* @author Administrator
*
*/
public class ClientTest { public static void main(String[] args) {
/*
* 产生代理对象
*/
HelloWSImplService factory = new HelloWSImplService();
HelloWSImpl helloWS = factory.getHelloWSImplPort();
System.out.println(helloWS); String result = helloWS.sayHello("Jack");
System.out.println(result);
}
}
测试结果:
客户端:
服务器端:
5.开发webservice的更多相关文章
- 使用JDK开发WebService
一.WebService的开发手段 使用Java开发WebService时可以使用以下两种开发手段 1. 使用JDK开发(1.6及以上版本) 2.使用CXF框架开发(工作中) 二.使用JDK开发Web ...
- Java开发Webservice的组件
参考:http://bbs.csdn.net/topics/390900831 转自:http://blog.csdn.net/dragoo1/article/details/50759222 htt ...
- 2.使用JDK开发webService
使用jdk开发webService需要注意:jdk版本必须1.6以及1.6以上! 以下webService的组成部分: server端和client端,通过服务器端(server)webService ...
- 利用NuSoap开发WebService(PHP)
利用NuSoap开发WebService(PHP) 分类: php 2010-09-08 12:00 5005人阅读 评论(1) 收藏 举报 webservicephpsoapstringencodi ...
- JAVA6开发WebService (四)——SAAJ调用WebService
转载自http://wuhongyu.iteye.com/blog/810571 前面写了个JAX-WS的小例子,看到用JAVA6开发WebService确实很简单,也很方便,不过前面也说了,JAVA ...
- Apache axis2 + Eclipse 开发 WebService
yd小结注意:1.axis2的2个插件的版本必须与引入的jar包匹配,如果不同则可能报以下错误 “没有实现序列化方法”或 “org.apache.axis2.databinding.utils.wri ...
- struts1+spring+myeclipse +cxf 开发webservice以及普通java应用调用webservice的实例
Cxf + Spring+ myeclipse+ cxf 进行 Webservice服务端开发 使用Cxf开发webservice的服务端项目结构 Spring配置文件applicationCont ...
- 使用cxf开发webservice应用时抛出异常
在使用cxf开发webservice应用时,报出了类似下面的错误 JAXB: [javax.xml.bind.UnmarshalException: unexpected element (uri:& ...
- WebService学习总结(三)——使用JDK开发WebService
一.WebService的开发手段 使用Java开发WebService时可以使用以下两种开发手段 1. 使用JDK开发(1.6及以上版本) 2.使用CXF框架开发(工作中) 二.使用JDK开发Web ...
- C# 开发XML Web Service与Java开发WebService
一.web service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量 ...
随机推荐
- Python中的条件判断和循环
1.使用elif代替else if,前者是后者的缩写. 2.所以for x in ...循环就是把每个元素代入变量x,然后执行缩进块的语句. 3.Python提供一个range()函数,可以生成一 ...
- Java_动态重新加载Class机制
Java动态重新加载Class 项目中使用到了动态重新加载Class的机制,作用是让一些代码上线之前可以在线上环境测试一下,当然,这是非常不好的测试机制,我刚来的时候也为这种机制感到惊讶—怎么可以在线 ...
- strftime 日期时间格式化
strftime() 函数根据区域设置格式化本地时间/日期,函数的功能将时间格式化,或者说格式化一个时间字符串. size_t strftime(char *strDest,size_t maxsiz ...
- VS2010+64+OSG3.2.1之五Plugins dae编译
VS2010+64+OSG3.2.1之五Plugins dae编译 转自:http://blog.csdn.net/nuaaqsm0915/article/details/38978971 Plugi ...
- FatMouse's Speed——J
J. FatMouse's Speed FatMouse believes that the fatter a mouse is, the faster it runs. To disprove th ...
- 前端Javascript书籍分享
早前在公司曾做过一些关于前端的技术分享,而每每跟大家谈到深处时,大家会疑惑这些知识点从何而来. 我会经常在内部去推荐自己读过的好书,希望大家在技术层面上都能更上一个台阶. 今天写下这个帖子一方面是记录 ...
- 利用JavaScript生成随机数字!
<!DOCTYPE html> <html> <head> <title>1-99的随机数字</title> <script type ...
- ajax跨域通过 Cors跨域资源共享 进行GetPost请求
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Ne ...
- WordPress忘记登录密码
后台的登录密码使用的是md5加密的,有时候会忘记登录密码,那么可以修改数据库,把密码改为你知道的字符串的md5加密值 如 hello对应的md5加密值为:5d41402abc4b2a76b9719d9 ...
- 去除magento多店铺URL地址中的“___from_store=”
magento 的多店铺功能,大多数情况下是根据语言来进行选择的,当添加了多店铺之后,一般情况下我们会选择开启添加store code到url地址中. Magento 自带的这种功能算是比较不错了,但 ...