Saturday, August 14, 2010

More on WebService Development using JAX-WS

For new project, I have to build an SOA layer in front of an engine that serves offers. The SOA layer will communicate via webservice as well.

Here's how I did it:

1. In eclipse, create a Dynamic Webcontent Project as a placeholder for the code stubs I am going to generate from my WSDL:








2. Get the WSDL and XSD files of the webservice you need to implement to the root project folder:
InteractService.wsdl


3. Use WSIMPORT to generate the code stubs. Eg. command I used:
"C:\Program Files (x86)\Java\jdk1.6.0_21\bin\wsimport" InteractService.wsdl -s src -d build\classes




4. Go back to Eclipse and refresh the project and you can see the source files generated:



5. In eclipse, create new a Dynamic Webcontent Project for my SOA layer:


6. Create and empty package for it:


7. Create my interface and implementation classes for the SOA:


8. Copy the required classes especially those that passes the objects as request and response:



9. Import the right package:



10. Ensure all the annotations are correct:



11. Build the project and ensure the classes are generated:



12. Generate the WSDL and artifacts using the following command:
"C:\Program Files (x86)\Java\jdk1.6.0_21\bin\wsgen" -cp ../build/classes -r ../WebContent -s . -d ../build/classes -keep com.singtel.ma.rto.RTOImpl -wsdl



13. Check that the classes are generated:



14. Create the war file for deployment:



15. Deploy on Glassfish:



16. Check that the Webservice is registered:



17. And the WSDL can be seen:



18. And there is a test inteface:

2 comments:

  1. If you need to add more directories in the classpath:
    "C:\Program Files (x86)\Java\jdk1.6.0_21\bin\wsgen" -cp ../build/classes;../WebContent/WEB-INF/li
    b/interact_client.jar -r ../WebContent -s . -d ../build/classes -keep com.singte
    l.ma.rto.RTOImpl -wsdl

    ReplyDelete
  2. it might be ok to get errors in the step 12 as long as the classes are generated correctly.

    ReplyDelete