CXF相关内容

 

.为什么要使用CXF来实现web service ,使用CXF的原因如下:

1.支持JAX-WS(Java™ API for XML Web Services)

CXF实现JAX-WS  APIs,使得构建web service更加简单,JAX-WS主要包含如下:

1)      JAVA类生成WSDL和由WSDL生成JAVA;

2)      提供你去创建接收服务端点简单消息的API;

3)      派发你去发送Xml消息给服务端点的API;

4)      …….

 

附:JAX-WS 简化了使用 Java 技术开发 Web服务的工作。并且通过对多种协议(SOAP 1.1SOAP 1.2XML)的支持,以及提供用于支持其他协议和 HTTP 的工具。JAX-WS 使用 JAXB 2.0 提供数据绑定服务,并支持通过定制来控制生成的服务端点接口。通过对标注的支持,JAX-WS 简化了 Web 服务开发,并缩小了运行时 JAR 文件的大小。 由于行业中不仅只使用 RPC Web 服务,还使用面向消息的 Web 服务。因此从名称中去掉了“RPC”,取而代之的是“WS”(当然表示的是 Web 服务)。因此 JAX-RPC 1.1 的后续版本是 JAX-WS 2.0——Java API for XML-based Web services

 

2.集成spring

Spring is a first class citizen with CXF.CXF支持spring2.0 xml 语法, making it trivial to declare endpoints which are backed by Spring and inject clients into your application.

 

3. 可插拔数据绑定

Aegis Databinding is our own databinding library that makes development of code-first web services incredibly easy. Unlike JAXB, you don't need annotations at all. It also works correctly with a variety of datatypes such as Lists, Maps, Dates, etc. right out of the box. If you're building a prototype web services that's really invaluable as it means you have to do very little work to get up and running (and one of the primary reasons XFire was started a while back)

4. RESTful Web服务

CXF enables the development of RESTful services via annotations using the HTTP Binding. Using URI templates and annotations you can bind a service operation to arbitrary URL/verb combinations. For instance, you can annotate a getCustom method with @Get @HttpResource("/customers/{id}"). CXF will then listen for GET requests on that URL and using the parameter at the {id} location as a parameter to the service.

5.支持WS-*

CXF支持各种Web Service规范包括WS-Addressing, WS-Policy, WS-ReliableMessaging WS-Security.

 

. 怎样去创建web service

CXF提供以下几种方式创建web service

1.      JAX-WS Annotated Services from Java  

java类创建web service,采用@WebService@WebMethod@WebParam@WebResult等注释去声明。其采用JAXB作为默认的数据绑定方式。

2.      JAX-WS Annotated Services from WSDL  

wsdl创建web service,首先编写一个WSDL,然后由CXF提供的WSDL2Java 命令工具产生基于 JAX-WS 注释的web service server 存根代码 。

用法:wsdl2java -p com -d src -all  aa.wsdl

-client 生成客户端测试web service的代码

-server 生成服务器启动web  service的代码

-impl 生成web service的实现代码

-ant  生成build.xml文件

-all 生成所有开始端点代码:types,service proxy,,service interface, server mainline, client mainline, implementation object, and an Ant build.xml file.

详细用法见:http://cwiki.apache.org/CXF20DOC/wsdl-to-java.html

3.      JAX-WS Providers

JAX-WS providers 允许你在消息级创建web 服务,   

JAX-WS Providers allow you to create services which work at the message level - as opposed to the operation level as with annotated classes. The have a single operation "invoke" which receives either the message payload (i.e. the SOAP Body) or the whole message itself

这个还有很多不清楚?

4.      Simple Frontend

有时并想用注释类或使用JAX-WS API.CXF包含一个简单的Frontend,允许你把任何类发布成web service且不需要额外的工作。不需要在业务接口中设置具体的协议、@Web Service@Web Method,仅仅需要创建与具体webservice技术无关的业务接口就可以了, 利用代理类进行发布服务和获取服务

详细见《使用Simple Frontend+Aegis方式发布并获取webservice

5.      Javascript

CXF提供javascript模块,允许你用javascript创建web service

详细见:http://cwiki.apache.org/CXF20DOC/javascript.html

 

.怎样去创建客户端

1.      WSDL2Java generated Client

详细见《快速上手使用CXF》中如何创建客户端,调用web service.

2.      JAX-WS Dispatch APIs

这个还有很多不清楚?

3.      JAX-WS Proxy

这个还有很多不清楚?

4.      Simple Frontend Client Proxy

详细见《使用Simple Frontend+Aegis方式发布并获取webservice

5.      Dynamic Client

这个还有很多不清楚?

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值