- JBoss Fuse – Issues and Solutions
- JBoss Fuse – Child Container
- JBoss Fuse – Fabric
- JBoss Fuse – AMQ With Camel
- JBoss Fuse – Apache AMQ
- JBoss Fuse – Rest Web Services
- JBoss Fuse – Apache CXF
- JBoss Fuse – Camel Concepts
- JBoss Fuse – Apache Camel
- JBoss Fuse – Apache Karaf
- What Is Fuse?
- JBoss Fuse - Introduction To ESB
- JBoss Fuse – Home
JBoss Fuse Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JBoss Fuse - Apache CXF
In this chapter, let us discuss about what Apache CXF is and how it can be helpful in developing SOAP and Rest Web Services.
What is Apache CXF?
Apache CXF is a web service development framework that can be utipzed to develop SOAP and Rest web services. CXF is fully comppant with JAX-RS and JAX-Ws standard.
It is most widely used web service development framework now. CXF has learned and improved over Axis2 which is now gradually being replaced by CXF.
CXF vs Axis2
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 Comppance | CSF is fully comppant with JAX-RS and JAX-WS |
Axis2 is not fully comppant 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
SOAP stands for Simple Object Access Protocol. It is a protocol for exchanging structured information over web services between two systems. It mostly repes on XML for structuring data and uses HTTP or SMTP for message negotiation and transmission.
There are two approaches to develop SOAP web services −
Code first − In this approach, WSDL is generated from code.
Contract first − In contract first, code is generated from WSDL.
SOAP Development Using CXF
Configure Maven
Add the following profile to your settings.xml of Maven.
<profiles> <profile> <id>Jboss-Fuse</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>fusesource</id> <url>http://repo.fusesource.com/nexus/content/groups/pubpc/</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> </profile> </profiles>
Create Skeleton
mvn archetype:generate -DarchetypeGroupId = org.apache.servicemix.toopng -DarchetypeArtifactId = servicemix-cxf-code-first-osgi-bundle -DarchetypeVersion=2012.01.0.redhat-60024 -DgroupId = org.fusesource.example -DartifactId = cxf-basic -Dversion = 1.0-SNAPSHOT
Build Web Service Project.
mvn clean install
Install web-service into Fuse using the following command.
JBossFuse:karaf@root>install -s mvn:org.fusesource.example/cxf-basic/1.0-SNAPSH
Check if bundle has registered SOQP web-service
Open URL http://localhost:8181/cxf
The web-service should be psted as follows.
Testing Web-Service
mvn -Pcpent
INFO − Creating Service {
} PersonService from class com.totorials.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] ------------------------------------------------------------------------Advertisements