= Java/ApacheCXF = http://cxf.apache.org/ Apache CXF is an open source services framework. CXF helps you build and develop services using frontend programming APIs, like JAX-WS and JAX-RS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI. == Sample SOAP Web Service == Structure: {{{ . |-- pom.xml |-- src | `-- main | |-- java | | `-- com | | `-- test | | |-- Calculator.java | | |-- ICalculator.java | | `-- TestService.java | `-- webapp | `-- WEB-INF | |-- applicationContext.xml | `-- web.xml `-- target }}} * mkdir -p /tmp/cxfSpringTest * cd /tmp/cxfSpringTest * mkdir -p src/main/webapp/WEB-INF/ * mkdir -p src/main/java/com/test/ * nano pom.xml {{{#!highlight xml 4.0.0 com.test cxfSpringTest 0.1 war org.apache.cxf cxf-rt-core 2.4.1 org.apache.cxf cxf-bundle-jaxrs 2.4.1 org.apache.cxf cxf-rt-frontend-jaxws 2.4.1 }}} * nano src/main/java/com/test/Calculator.java {{{#!highlight java package com.test; public class Calculator implements ICalculator { public Calculator() { System.out.println("Calculator created "); } public long add(long num1, long num2) { return (num1 + num2); } public long subtract( long num1, long num2 ){ return num1 - num2; } } }}} * nano src/main/java/com/test/ICalculator.java {{{#!highlight java package com.test; import javax.jws.WebService; @WebService public interface ICalculator { public long add(long num1 , long num2 ); public long subtract(long num1, long num2 ); } }}} * nano src/main/webapp/WEB-INF/applicationContext.xml {{{#!highlight xml }}} * nano src/main/webapp/WEB-INF/web.xml {{{#!highlight xml CXFServlet org.apache.cxf.transport.servlet.CXFServlet CXFServlet /* org.springframework.web.context.ContextLoaderListener Spring org.springframework.web.servlet.DispatcherServlet 0 }}} * nano src/main/java/com/test/TestService.java {{{#!highlight java package com.test; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path("/testSvc") public class TestService { @GET @Path("/{param}") public Response getMsg(@PathParam("param") String msg) { String out = String.format("testSvc returns %s", msg); return Response.status(200).entity(out).build(); } } }}} mvn clean compile package # builds cxfSpringTest-0.1.war Test links: * http://localhost:8080/cxfSpringTest-0.1/services * http://localhost:8080/cxfSpringTest-0.1/testSvc/1001