Objective
There has been no progress in the article "SOA ecosystem approach" in the draft blog, and it is felt that it is necessary to articulate the concepts of SOA, Web Service (WS), and rest.
Heaven must be site, here to record some "lowbrow" practice, the main study of Apache Axis2 and Apache CXF two Java Service Development framework, first from CXF.
Directory
1 Tools
2 Apache CXF configuration in Eclipse
3 Running Instances
4 references
Content
1 Tools
Windows 7
Eclipse Juno (4.2.0, JEE version, build-id:20120614-1722)
Apache CXF 2.4.2 (newer version 2.7.11 some inexplicable errors during configuration, fall back to the lower version), CXF extract directory as Cxf_home
Apache Tomcat 7.0
2 Apache CXF configuration in Eclipse
Window->preferences->web SERVICES->CXF 2.x PREFERENCES->CXF Runtime Add runtime, specify CXF extract directory
3 Running Instances
Expected target: Create WS from bottom up (bottom-up), deploy WS to the servlet container, observe the WSDL of the service, call the WS interface through the browser.
Create dynamic WEB Project projects
Project structure (add index.html)
The expected project Facets
Before
After
Writing Service Implementation classes
Packagecom.spike.cxf;ImportJavax.jws.WebService;/*** Description:helloservice implementation<br/> * date:2014-5-11 pm 7:59:33*/@WebService (targetnamespace= "http://cxf.spike.com/", PortName = "Helloserviceimplport", ServiceName = "Helloserviceimplservice") Public classHelloserviceimpl { PublicString getversion () {return"1.0"; } Publicstring Greeting (string user) {return"Hello" + user + "!"; }}
Add CXF Facets based on Dynamic Web project: Right-click service implementation class, Generate Web service
Configuring the WS Type
Service Endpoint Interface (SEI) selection or creation, where default
Select the Service method note, where the default
CXF JAVA2WS configuration, here Default
Start the service (actually a servlet container) wait
Service Publishing mode setting, default here
Click on the project structure after finish
Package Explorer
Project Explorer
"Configuration" of the servlet container, with 8082 ports selected
Access Service Http://localhost:8082/CXF/services
Click the WSDL link http://localhost:8082/CXF/HelloServiceImplPort?wsdl
Invoking the Service interface method
(1) http://localhost:8082/CXF/services/HelloServiceImplPort/getVersion
(2) Http://localhost:8082/CXF/services/HelloServiceImplPort/greeting?arg0=zhoujiagen
4 references
[1] jax-ws with Apache CXF and Eclipse [step1] http://angelozerr.wordpress.com/2011/08/23/jaxwscxf_step1/
[2] Jax-ws with Apache CXF and Eclipse [step2] http://angelozerr.wordpress.com/2011/08/24/jaxwscxf_step2/