Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • From Eclipse main menu, select File->New->Other

  • In the New dialog, select Web->Dynamic Web Project and click Next

    Image Added

  • Type jaxws-rest-converterclient as the Project Name and click Next

    Image Added

  • On the Project Facets page, the default selections are enough.

    Image Added

  • Make sure that the check box Generate Deployment Descriptor is selected and click Next

    Image Added

  • On the Geronimo Deployment Page modify the Group Id to org.apache.geronimo.samples.jaxws.rest and the Artifact Id to jaxws-rest-converterclient.

    Image Added

  • Click Finish

Developing the Web based Client

  • Right Click the jaxws-converterclient, and Select New->JSP

  • Name the jsp as index.jsp and click Finish

    Image Added

  • Add the following code to the index.jsp

...

  • Right click again and add another jsp named post.jsp

    Image Added

  • Add the following code to post.jsp

...

  • Right click again and add a Servlet named ConverterHandler

    Image Added

  • Add the following code to ConverterHandler.java

...

  • Right click on the Apache Geronimo Server Runtime present in the servers view and select Add and Remove Projects

  • Add jaxws-rest-converterclient to configured projects list and then click Finish

    Image Added

  • Wait for some time till the server status changes to Synchronized

...

  • Right click the index.jsp present under WebContent directory of our project and select Run As->Run On Server

  • In the popup, check the check box Always use this server when running the project and then click Finish

  • Now Eclipse will try to open the jsp in a web browser which shows you a form to enter amount in Dollars.

  • Enter any amount and press submit, the jsp should display the result that is returned by the web service.

    Image Added

Info
Test via Post
Test via Post

The code for testing the RESTful service via POST method hasn't been added to the ConverterHandler.
A sample post file might look like this

Code Block
titleSampleRequest.xml
borderStylesolid
<?xml version="1.0" encoding="UTF-8"?>
<amount dollars="23" />

This completes the development of a simple RESTful client that consumes a RESTful Web Service that is already deployed on the server.