文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > JAX-WS 开发 web service
侵权投诉

JAX-WS 开发 web service

JAX-WS 开发 web service

c Hello() {}

@WebMethod()
public String sayHello(String name) {
return message + name + ".";
}
}
package helloservice.endpoint;
import javax.jws.WebService;

@WebService()
public class Hello {
private String message = new String("Hello, ");

public Hello() {}

@WebMethod()
public String sayHello(String name) {
return message + name + ".";
}
}@WebService() 表明这是一个 web service, @WebMethod() 表示这个方法是暴露给 clients 的.

b) 编译这个实现类:

wsgen -d build -s build -classpath build helloservice.endpoint.Hello

-d 指定生成的class文件的输出位置. -s 指定生成的源文件的输出位置. -classpath 指定了要编译文件的位置, 在本例中是 endpoint 实现类, helloservice.endpoint.Hello, 在build目录下.

c) 打包并发布该服务:

在发布时, 服务器和 JAX-WS 运行环境会生成 web 服务调用所必需的一些资源, 包括 WSDL 文件.

发布后, 访问 doc.guandang.net 可看到生成的 WSDL 文件内容.

d) JAX-WS Client:

JAX-WS client 通过一个 stub 调用 web 服务, 这个 stub 是一个本地对象, 扮演远程服务的代理. Stub 在开发阶段使用 wsimport 工具创建, 该工具能够基于 WSDL 文件产生 JAX-WS portable artifacts.

步骤如下:

使用 javax.xml.ws.WebServiceRef 注释声明一个指向一个 web service 的引用. WebServiceRef 使用 wsdlLocation element 指定已发布服务的 WSDL 文件的 URI.
@WebServiceRef(wsdlLocation=”doc.guandang.net”)
static HelloService service;
通过调用该服务的 getHelloPort 获取该服务的一个 proxy, 也俗称为 port.
Hello port = service.getHelloPort();
该 port 实现了该服务所定义的 SEI.
调用该 port 的 sayHello 方法, 给该服务传递一个 name.
String response = port.sayHello(name);
完整代码:

view plaincopy to clipboardprint?
package simpleclient;

import javax.xml.ws.WebServiceRef;
import helloservice.endpoint.HelloService;
import helloservice.endpoint.Hello;

public class HelloClient {

@WebServiceRef(wsdlLocation = "doc.guandang.net;)
static HelloService service;

public static void main(String[] args) {
try {
HelloClient client = new HelloClient();
client.doTest(args);
} catch (Exception e) {
e.printStackTrace();
}
}

public void doTest(String[] args) {
try {
System.out.println("Retrieving the port from the following service: " + service);
Hello port = service.getHelloPort();
System.out.println("Invoking the sayHello operation on the port.");
String name;
if (args.length > 0) {
name =

上一页第2页

你可能喜欢

热门文档

相关文档

  • 使用JAX-WS开发WebService入门教程

    使用JAX-WS开发WebService入门教程_信息与通信_工程科技_专业资料。这是学习webservice的很好的入门教程 程序员的入门必看教程 里面写的很清楚使用...

  • 基于JAX-WS开发Web Service

    使用MyEclipse 8.5 基于 JAX-WS 开发 Web Service ? 首先需要创建一个 Web Service 的项目,点击 File - New - Web Service Project ? 建立服务类,其实就是...

  • 基于JAX-WS 设计开发WebService

    基于JAX-WS 设计开发WebService_IT/计算机_专业资料。基于JAX-WS 设计开发WebService基于JAX-WS 开发 Web Service 2008-05-06 基于JAX-WS 设计开发 Web Service ...

  • 基于JAX-WS开发部署WebService

    基于JAX-WS开发部署WebService_IT/计算机_专业资料。本文档举例介绍了基于JAX-WS开发Webservice的步骤基于JAX-WS 开发部署 WebService 1.1 基于 wsdl 开发 WebService...

  • myeclipse6.5上基于JAX-WS开发Webservice(中文示例)

    myeclipse6.5上基于JAX-WS开发Webservice(中文示例)_计算机软件及应用_IT/计算机_专业资料。译文:myeclipse6.5 上基于 JAX-WS 开发 Webservice(中文示 例) 在网...

  • web service 入门 jax-ws

    web service 入门 jax-ws_计算机软件及应用_IT/计算机_专业资料。webservice的jax...客户端开发:调用别人发布的 WebService 服务,大多数人从事的开发都属于这个方面,...

  • JAX-WS 开发 Web 服务

    JAXJAX-WS 开发 Web 服务 JAX-WS 是用于简化使用 Java 构造 Web 服务和 Web...wsgen tutorial.service.OrderProcessService -wsdl wsgen 工具提供了大量的选项,...

  • 使用Myeclipse6.5开发基于JAX-WS的Web service实例

    使用Myeclipse6.5开发基于JAX-WS的Web service实例_解决方案_计划/解决方案_应用文书。使用Myeclipse6.5开发基于JAX-WS的Web service实例今日...

  • JAX-WS实现Web Service程序

    JAX-WS实现Web Service程序_互联网_IT/计算机_专业资料。WEBJAX-WS 实现 Web Service 程序 JAX-WS 实现 Web 服务程序的方法要比 XFire 简单的多,仅仅通过编写服...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email