1、服务器端建立
1.1、创建接口
[java] view plaincopy
@WebService
public interface IWebService {
int add(int a, int b);
int subtract(int a, int b);
}
1.2、创建实现类
[java] view plaincopy
@javax.jws.WebService(endpointInterface = "org.gwr.service.IWebService")
public class WebService implements IWebService {
@Override
public int add(int a, int b) {
System.out.println(a + "+" + b + "=" + (a + b));
return a + b;
}
@Override
public int subtract(int a, int b) {
System.out.println(a + "-" + b + "=" + (a - b));
return a - b;
}
}
1.3、部署服务
[java] view plaincopy
public class ReleaseService {
public static void main(String[] args) {
String address = "http://localhost:8888/ns";
Endpoint.publish(address, new WebService());
}
}
2、客户端建立
调用webService
[java] view plaincopy
public class CallService {
public static void main(String[] args) {
// 创建访问wsdl服务地址的url
try {
URL url = new URL("http://localhost:8888/ns?wsdl");
// 通过Qname指明服务的具体信息
QName sname = new QName("http://service.gwr.org/",
"WebServiceService");
// 创建服务
Service service = Service.create(url, sname);
// 实现接口
IWebService ms = service.getPort(IWebService.class);
System.out.println(ms.add(12, 33));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
分享到:
相关推荐
开发基于JWS的webservice并通过jun-jaxws发布所需的jar包
NULL 博文链接:https://xiongpan0807.iteye.com/blog/1827835
使用jws 发布webservice (服务端、客户端代码)
jws与spring发布WebService
webService的实现方式之一JWS,有需要的同学可以下载代码抽空研究;
内容概要:基于jws发布webservice服务,包括服务端、客户端示例代码 适用人群:webservice开发人员 文档说明:https://blog.csdn.net/huryer/article/details/124702107?spm=1001.2014.3001.5501
java开发webservice入门最全讲解demo
使用JAX-WS(JWS)发布WebService 使用myeclipse开发java的webservice的两种方式 方式一: (此方式只能作为调试,有以下bug:jdk1.6u17?以下编译器不支持以Endpoint.publish方式发布document方式的soap,必须在...
JAVA6开发WebService JWS示例
在网上找了很久的资料,接口已经跟客户对接,特编写了代码文档和附带jar包,并含其他网站的参考地址,注意jdk环境要1.6或以上版本
my-webservice 是一个项目网络服务。 使用 javax.jws 包。 网址:
jax webservice 服务器和客户端示例程序
jaxws java webservice需要的jar包
这具是JWs开源项目
一、利用jdk web服务api实现,这里使用基于 SOAP message 的 Web 服务 1.首先建立一个Web services EndPoint: Java代码 package Hello; import javax.jws.WebService; import javax.jws.WebMethod; import ...
包含jws所需的jar包 edu.mit.jwi和edu.sussex.nlp.jws.beta.11以及基于JWS写的词语相似度比较算法和JWS相关的帮助文档
import javax.jws.WebService; import javax.jws.WebMethod; import javax.xml.ws.Endpoint; @WebService public class Hello { @WebMethod public String hello(String name) { return "Hello, " + name + ...
jws-1.6.1.zip java jws环境安装包,....
Axis的jws发布WebService Axis的wsdd模式发布WebService Axis中传递复杂对象和内部类 Axis中的handler、chain的特性 Axis中处理异常信息 Axis中传递文件信息 Axis常用命令介绍 Axis 提供的工具和调试 Axis 的wsdl...