001 web服务概念
来源:互联网 发布:sql server 删除实例 编辑:程序博客网 时间:2024/05/22 13:19
正在学习web服务,看书笔记
web服务是什么?
1、网络程序
2、分布式应用开发的工具
特点?
1、开发架构。基于http、xml 、现有的安全等标准
2、语言透明
3、模块化:适合网络进程间的通讯和整合
网络程序1暴露一个接口iter1(包含一个或多个方法)供其他的程序调用,其他程序利用iter1的方式非常的简单,很对象化
web服务用WSDL来描述一个java服务程序的接口
采用SOAP来传送消息 。SOAP是一个在分布式环境中用来传送结构化信息的轻量级协议,用xml来描述一个消息框架
一个SEI
package ch01.ts; // time server
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC) // more on this later
public interface TimeServer {
@WebMethod String getTimeAsString();
@WebMethod long getTimeAsElapsed();
}
一个SIB
package ch01.ts;
import java.util.Date;
import javax.jws.WebService;
@WebService(endpointInterface = "ch01.ts.TimeServer")
public class TimeServerImpl implements TimeServer {
public String getTimeAsString() { return new Date().toString(); }
public long getTimeAsElapsed() { return new Date().getTime(); }
}
通过EndPoit发布
package ch01.team;
import javax.xml.ws.Endpoint;
class TeamsPublisher {
public static void main(String[] args) {
int port = 8888;
String url = "http://localhost:" + port + "/ts";
Endpoint.publish(url, new TimeServerImpl());
}
}
对web服务的访问
package ch01.ts;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;
class TimeClient {
public static void main(String args[ ]) throws Exception {
URL url = new URL("http://localhost:8888/ts?wsdl");
// Qualified name of the service:
// 1st arg is the service URI
// 2nd is the service name published in the WSDL
QName qname = new QName("http://ts.ch01/", "TimeServerImplService");
// Create, in effect, a factory for the service.
Service service = Service.create(url, qname);
// Extract the endpoint interface, the service "port".
TimeServer eif = service.getPort(TimeServer.class);
System.out.println(eif.getTimeAsString());
System.out.println(eif.getTimeAsElapsed());
}
}
- 001 web服务概念
- Web服务(Web Service)相关概念
- ONJava.com -- Web 服务实现中的概念分离 --> page 1
- ONJava.com -- Web 服务实现中的概念分离 --> page 2
- ONJava.com -- Web 服务实现中的概念分离 --> page 3
- Web服务请求异步化介绍(概念篇)
- Web服务请求异步化介绍(概念篇)
- Web服务请求异步化介绍(概念篇)
- Web服务请求异步化介绍(概念篇)
- API(应用编程接口或web服务)概念问题
- SOA 中新出现的一些概念:XML Feeds 和聚合的 Web 服务
- web策略类游戏开发(一) WebGame架构篇(设计万人服务架构等概念)
- web 服务
- WEB服务
- Web 服务
- Web服务
- web服务
- web 服务
- A. Word
- 换个心境搞IT–在IT职场如何打拼?
- Hdu 1059 Dividing -- 多重背包
- 黑马程序员-java io(Input Output)流
- 黑马程序员_张孝祥7k面试题_银行调度系统
- 001 web服务概念
- Linux平台下搭建OgreKit on Android开发环境
- Jwchat 的安装和配置、Service unavailable、Authorization failed问题汇总
- 我的hibernate通用dao层 .
- 专题技巧浅析
- 进程与线程的区别
- chukwa在数据收集处理方面的应用
- 黑马程序员-java 多线程
- MyEcilpse10 优化性能