Sunday, March 28, 2010

Easy Web Service And Test in 5 Minutes

This post will show how to quickly make a web service and test it in less than 5 minutes.

Tools you will need:

NetBeans 6.8 (choose to install GlassFish with the IDE)
SOAPUI 3.5


First, make your NetBeans project. Make it a Web App.



Choose defaults for the deployment options:






Right-click the source package and choose to add a new Web Service:



Give the Web Service a name. My examples often deal with the game of bowling.....



Put the cursor in the body of the Web Service class and right click. Choose to 'Insert new code', make it a Web Service, and add the method signature you want.







Add some logic for your method. When you're done, right-click the Application in the Applications tab and choose 'Clean and Build', then 'Deploy' (after you've cleaned up any compile errors, if there are any.)



Now choose the 'Services' tab. You need to go get the WSDL for your Web Service so you can test it....



Choose 'View Endpoint'....



Click the link for your WSDL, and copy it into your clipboard. You'll be using it in a few seconds....




Now to test the Web Service! Fire up SOAPUI, and start a new Project. Paste your WSDL URL (from the address you got after clicking the 'view WSDL' link a bit above).




Now alter the sample SOAP message SOAPUI has kindly provided you. In my screenshots, I'll check to see if a nine count makes a strike. (It does not, of course.)





That's it! A couple of very important points:

This is a 'Bottom-up' Web Service. (One where you start with code, not start from WSDL). These are easy to develop, but may not fit well in your 'Production' environment.

There are other ways to test your Web Service, including facilities within NetBeans itself. I wanted to use SOAPUI, though, because it's a great tool that's very versatile.


Happy Coding!

3 comments:

rajeev Samuel said...

for more information on net beans visit http://www.softlogiccorp.com

Daniel Siwiec said...

Great post Rick!

I've recently found similar articles for Eclipse IDE on:

Development

Deployment

Cheers!

Daniel

jaring safety said...


Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
jaring futsal | jaring golf | jaring pengaman proyek |
jaring pengaman bangunan | jaring pengaman gedung
http://www.jual-jaring.blogspot.com/
http://www.agen-jaring.blogspot.com/
http://www.pancasamudera-safetynet.blogspot.com/
http://www.toko-jaring.blogspot.com/
http://www.pusat-jaring.blogspot.com/
http://jualjaringpengaman.blogspot.com/
https://pancasamudera.wordpress.com/
https://pasangjaringfutsal.wordpress.com/
https://jualtambangmurah.wordpress.com/
https://tokojaring.wordpress.com/
https://jualjaringfutsal.wordpress.com/
https://jaringfutsal.wordpress.com/