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的更多相关文章

  1. 使用JDK开发WebService

    一.WebService的开发手段 使用Java开发WebService时可以使用以下两种开发手段 1. 使用JDK开发(1.6及以上版本) 2.使用CXF框架开发(工作中) 二.使用JDK开发Web ...

  2. Java开发Webservice的组件

    参考:http://bbs.csdn.net/topics/390900831 转自:http://blog.csdn.net/dragoo1/article/details/50759222 htt ...

  3. 2.使用JDK开发webService

    使用jdk开发webService需要注意:jdk版本必须1.6以及1.6以上! 以下webService的组成部分: server端和client端,通过服务器端(server)webService ...

  4. 利用NuSoap开发WebService(PHP)

    利用NuSoap开发WebService(PHP) 分类: php 2010-09-08 12:00 5005人阅读 评论(1) 收藏 举报 webservicephpsoapstringencodi ...

  5. JAVA6开发WebService (四)——SAAJ调用WebService

    转载自http://wuhongyu.iteye.com/blog/810571 前面写了个JAX-WS的小例子,看到用JAVA6开发WebService确实很简单,也很方便,不过前面也说了,JAVA ...

  6. Apache axis2 + Eclipse 开发 WebService

    yd小结注意:1.axis2的2个插件的版本必须与引入的jar包匹配,如果不同则可能报以下错误 “没有实现序列化方法”或 “org.apache.axis2.databinding.utils.wri ...

  7. struts1+spring+myeclipse +cxf 开发webservice以及普通java应用调用webservice的实例

    Cxf + Spring+ myeclipse+ cxf 进行  Webservice服务端开发 使用Cxf开发webservice的服务端项目结构 Spring配置文件applicationCont ...

  8. 使用cxf开发webservice应用时抛出异常

    在使用cxf开发webservice应用时,报出了类似下面的错误 JAXB: [javax.xml.bind.UnmarshalException: unexpected element (uri:& ...

  9. WebService学习总结(三)——使用JDK开发WebService

    一.WebService的开发手段 使用Java开发WebService时可以使用以下两种开发手段 1. 使用JDK开发(1.6及以上版本) 2.使用CXF框架开发(工作中) 二.使用JDK开发Web ...

  10. C# 开发XML Web Service与Java开发WebService

    一.web service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量 ...

随机推荐

  1. Android weight属性详解

    android:layout_weight是一个经常会用到的属性,它只在LinearLayout中生效,下面我们就来看一下: 当我们把组件宽度设置都为”match_parent”时: <Butt ...

  2. mysql event_scheduler运行一段时间后 自动关闭

    应该是你重启过电脑或重启过服务了.  SELECT * FROM mysql.event;SET GLOBAL event_scheduler = 1; -- 开启定时器 0:off 1:on SHO ...

  3. 安装phonegap3.2

    安装phonegap3.2,要用node.js,还要安装git  

  4. quick-3.5 eclipse android

    quick-3.5 eclipse android  上遇到的 问题 首先是已经安装了SDK NDK ADT 环境变量都已经配置好了 直接打开项目然后运行 却出现这个鸟问题如图: NDK_ROOT = ...

  5. Dom4jUtils.java

    package com.vcredit.framework.utils; import org.apache.commons.lang3.StringUtils;import org.dom4j.Do ...

  6. openstack-lanch an instance and nova compute log analysis

    1. how to launch an instance: [root@localhost ~(keystone_admin)]# nova flavor-list+----+-----------+ ...

  7. GCC编译C代码

    C程序的编译过程       常用文件的后缀名: gcc编译c代码 1.gcc 常用编译选项: 2.gcc编译方法 testc.c: #include <stdio.h> int main ...

  8. Pycharm Professional Edition 激活码(license)

    http://blog.csdn.net/yangysc/article/details/52355865 43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiw ...

  9. js window.onload 的一个验证

    window.onload必须等到页面内包括图片的所有元素加载完毕后才能执行. 以下验证是否是图片加载完成后才执行 <img class="icon" id="ic ...

  10. Interview Tests

    1,wpf特点: 1:MVVM模式. 2:数据和视图分离 3:高级的数据模板功能 4:高级数据绑定功能 5:高级动画支持 6:高级图形和3D支持 7:灵活的控件组合 2,依赖属性的原理:Depende ...