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)

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!


rajeev Samuel said...

for more information on net beans visit

Daniel said...

Great post Rick!

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





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