📅  最后修改于: 2020-10-13 08:10:38             🧑  作者: Mango
在本章中,让我们讨论什么是Apache CXF以及它如何对开发SOAP和Rest Web Services有所帮助。
Apache CXF是一个Web服务开发框架,可用于开发SOAP和Rest Web服务。 CXF完全符合JAX-RS和JAX-Ws标准。
它是目前使用最广泛的Web服务开发框架。 CXF已经学习并改进了Axis2,而Axis2现在逐渐被CXF取代。
CXF | Axis2 | |
---|---|---|
Improvements | CXF is most used framework as of now.
It has lot improvements over Axis2 |
Axis2 is gradually being replaced by CXf.
It requires more code as compared to CXF |
Code required | CXF requires less code as compared to Axis2 | Axis2 requires more code comparatively |
Standard Compliance | CSF is fully compliant with JAX-RS and JAX-WS | Axis2 is not fully compliant with JAX-RS and JAX-WS |
Compatible with Spring | Yes | No |
Separation of front-ends | Clean separation of front-end from JAX-WS code | No clean separation is provided |
SOAP代表简单对象访问协议。它是用于在两个系统之间通过Web服务交换结构化信息的协议。它主要依靠XML来结构化数据,并使用HTTP或SMTP进行消息协商和传输。
开发SOAP Web服务有两种方法-
将以下配置文件添加到Maven的settings.xml中。
Jboss-Fuse
true
fusesource
http://repo.fusesource.com/nexus/content/groups/public/
false
true
mvn archetype:generate
-DarchetypeGroupId = org.apache.servicemix.tooling
-DarchetypeArtifactId = servicemix-cxf-code-first-osgi-bundle
-DarchetypeVersion=2012.01.0.redhat-60024
-DgroupId = org.fusesource.example
-DartifactId = cxf-basic
-Dversion = 1.0-SNAPSHOT
构建Web服务项目。
mvn clean install
使用以下命令将Web服务安装到Fuse中。
JBossFuse:karaf@root>install -s mvn:org.fusesource.example/cxf-basic/1.0-SNAPSH
检查捆绑包是否已注册SOQP Web服务
开启网址http:// localhost:8181 / cxf
该Web服务应列出如下。
测试网络服务
mvn -Pclient
INFO -创建服务{ http://ws.totorials.com/从类com.to} PersonService
torials.ws.Person
Invoking getPerson...
getPerson._getPerson_personId = Guillaume
getPerson._getPerson_ssn = 000-000-0000
getPerson._getPerson_name = Guillaume
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.668 s
[INFO] Finished at: 2016-02-15T21:01:20+05:30
[INFO] Final Memory: 10M/37M
[INFO] ------------------------------------------------------------------------