Java Web Services Up and Running 2nd阅读笔记

Java Web Services Up and Running 2nd阅读笔记

快速入门

web service是如何发展起来的?

为了解决开发的易用性,轻量级,语言无关性。

  1. XML-RPC 基于HTTP传输,XML格式的文本,轻量级

  2. 重量级的Distributed Object Architecture 如J2EE, 基于java RMI (远程方法调用) , import java.util.List; public interface BenefitsService extends java.rmi.Remote { public List getBenefits(Emp emp) throws RemoteException; }
    client端维护一个stub, 客户端需要服务端一样的POJO类, 使用marshaling/unmarshaling

  3. Web Service的简化操作
    客户端和服务端基于HTTP协议交换XML数据,不要求相同的语言实现,你可以是面向对象语言,面向过程函数,或者其他方式。

non-java types ---> convert to  XML ---> Convert to Java, 

为何REST-STYLE SERVICES很流行?**

为了降低逐渐增加的SOAP的复杂性
内容载体更丰富
REST and SOAP are quite different. SOAP is a messaging protocol in which the messages
are XML documents, whereas REST is a style of software architecture for distributed
hypermedia systems, or systems in which text, graphics, audio, and other media are
stored across a network and interconnected through hyperlinks.

HTTP既是传输协议,又是消息系统。所负载的消息通过MIME(Multipurpose Internet Mail Extension) type指定不同的格式,如text/html, application/octet-stream, audio/mpeg3等等

HTTP提供返回状态码表明请求的处理结果

对于Rest风格的web service系统,Client端做两件事:
a) 通过URL命名目标资源
b) 指定verb (HTTP method)

Table 1-2. HTTP verbs and their CRUD operations

HTTP verbCRUD operation
POSTCreate
GETRead
PUTUpdate
DELETEDelete
Created with Raphaël 2.1.2ClientClientservletservletbackend JavaBeansbackend JavaBeansGET requestsdata?dataservices responses

The Restful web service APIs include:
• HttpServlet and its equivalents (e.g., JSP scripts)
• JAX-RS, which has various implementations
• Restlet, which is similar in style to JAX-RS
• JAX-WS @WebServiceProvider, which is a relatively low-level API

@GET, @POST @PUT @DELETE

JAW-WS is an API used mostly for SOAP-based services but can be used for REST-style
services as well.

annotationscope
@WebServiceProviderfor both SOAP/RESTFUL, lower-level API
@WebServicefor SOAP (JAX-WS) only
@GET, @POST, @PUT, @DELETEfor JAX-RS/ Restlet
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值