WebService 的两种实现:
- SOAP
- Restful
关于各自的详细说明,参见
SOAP Simple Object Access Protocol 简单对象访问协议
Restful Representation State Transfer 表现层状态转化
Apache CXF Java 中实现 WebService 的工具
Apache CXF is an open source services framework.
CXF helps you build and develop services using frontend programming APIs, like JAX-WS and JAX-RS.
These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.
SOAP
Exposing pieces of application logic (not data) as service. (关注在应用逻辑层面)
Focus on accessing named operations (关注在操作,例如 transferMoney(from, to, amount)
)
Only Permit XML (只支持 XML 格式)
跨语言,跨平台
重量级: 适用于银行系统
- 支持安全 WS-Security
- 支持事务 WS-AtomicTransaction
- 支持消息 WS-ReliableMessaging
Restful
Exposing public API to handle CRUD operations on data. (关注在数据层面)
Focus on accessing named resources (关注在资源,例如 getUser(id)
)
Permit many data format (支持多种格式)
需要 HTTP
轻量级: 不支持 ACID,不支持消息