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.1、SOAP 1.2、XML)的支持,以及提供用于支持其他协议和 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 这个还有很多不清楚? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |