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. R中一切都是vector

    0.可以说R语言中一切结构体的基础是vector! R中一切都是vector,vecotor的每个component必须类型一致(character,numeric,integer....)!vect ...

  2. final阶段成员贡献分

    项目名:连连看 组名:天天向上 组长:王森 组员:张政.张金生.林莉.胡丽娜 final阶段各组员的贡献分分配如下: 姓名 个人工作量 组长评价 个人评价 团队贡献总分 张政 11 7 6 6.00 ...

  3. C#网络编程之---TCP协议的同步通信(二)

    上一篇学习日记C#网络编程之--TCP协议(一)中以服务端接受客户端的请求连接结尾既然服务端已经与客户端建立了连接,那么沟通通道已经打通,载满数据的小火车就可以彼此传送和接收了.现在让我们来看看数据的 ...

  4. INotifyPropertyChanged, Interface

    Data Object(class) impliment INotifyPropertyChanged; then the Object can update BindingSource. Impli ...

  5. phpv6_css

    global @charset "utf-8"; /* CSS Document */ /*格式化样式*/ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3, ...

  6. 阿里云服务器Linux CentOS安装配置(十)安装Discuz

    0.登录阿里云,停止实例,重新初始化磁盘. 如果不这么做,安装的discuz页面样式丢失,没法解决. 1.安装apache yum install httpd httpd-devel -y 2.安装m ...

  7. mysql5.1升级到mysql5.6

    这么大跨度的升级,本身不推荐.升级应该是循序渐进的,以防止不兼容.如果确实要这么做,你先要确保你的客户端管理工具要能兼容,比如phpmyadmin,此次升级依然存在一个问题,mysql server和 ...

  8. 20145220&20145209&20145309信息安全系统设计基础实验报告(3)

    20145220&20145209&20145309信息安全系统设计基础实验报告(3) 实验报告链接: http://www.cnblogs.com/zym0728/p/6132243 ...

  9. Source Insight设置

    Source Insight设置 1.背景色选择     要改变背景色Options->preference->windows background->color设置背景色,设置自定 ...

  10. linux实践之ELF文件分析

    linux实践之ELF文件分析 下面开始elf文件的分析. 我们首先编写一个简单的C代码. 编译链接生成可执行文件. 首先,查看scn15elf.o文件的详细信息. 以16进制形式查看scn15elf ...