How to call a web service from a browser

By Alvin J. Alexander, devdaily.com

I've been working with web services a lot this past week, specifically with Apache Axis2, and here are a few notes about hitting one of my web services from a browser.

Looking at the WSDL for a web service

To view the WSDL document for the web service I created named UserService, I just went to the following URL in my browser:

http://localhost:8080/axis2/services/UserService?wsdl 

For my purposes right now I'm just running the web service using the Axis2 server, so my UserService web service is available at that URL.

Calling a web service set method

To call a method on my web service named setTwoNumbers, which shows up in the WSDL as setTwoNumbers(int param0, int param1), I typed this as a URL in my browser:

http://localhost:8080/axis2/services/UserService/setTwoNumbers?param0=5¶m1=10 

Calling a web service get method

After first calling my method to set the two parameters, I was then able to call these two methods and get my numbers (5 and 10) back from them:

http://localhost:8080/axis2/services/UserService/getNum1 
http://localhost:8080/axis2/services/UserService/getNum2 

Follow-up

As a sad follow-up, while this tip works just fine when you're using Axis or Axis2, it does not work if you're using XFire. There are other ways to test XFire web services from tools like Eclipse, but I like the browser approach as a quick test.


devdaily logo