Mega Code Archive

 
Categories / Java / Web Services SOA
 

This demo shows how to create RESTful services using CXFs HTTP binding

This demo shows how to create RESTful services using CXF's HTTP binding. The server in the demo creates 3 different endpoints: a RESTful XML endpoint, a RESTful JSON endpoint, and a SOAP endpoint. [RUNNING THE DEMO] The demo has a class called com.acme.customer.Main which starts up various endpoints. To start this server run the command: $ ant server Once it is running try going to the following URLs: http://localhost:8080/xml/customers http://localhost:8080/json/customers http://localhost:8080/xml/customers/123 http://localhost:8080/json/customers/123 These will serve out XML and JSON representation of the resources. There is an HTML page that is served by CXF so you can try using the JSON service via Javascript. Just go to: http://localhost:8080/test.html Included are some example JSON and XML files so you can add or update customers using wget. Try the following commands and look at the results: wget --post-file add.json http://localhost:8080/json/customers wget --post-file add.xml http://localhost:8080/xml/customers wget --post-file update.xml http://localhost:8080/xml/customers/123 And if you are interested in SOAP you can try the SOAP endpoint: http://localhost:8080/soap?wsdl [RUNNING THE CLIENT] The demo also includes a Client class which accesses data using  HTTP. To run this demo, do: $ ant client          XFire-CXF-restful_http_binding.zip( 19 k)