Java – Accessing a web service from your browser

axis2browserjavaosgiweb services

I'm relatively new to how web services work so I've gone though a tutorial from
http://blog.saminda.org/2008/07/light-weight-osgi-based-axis2-powered.html
which sets up a web service that prints hello.

The code to print out hello is here. In the same project here, there is another web service that adds two numbers together.

To access the "hello" web service, I just go to my browser and go to http://localhost:8080/bridge/services/Version/getVersion .

But how do I do that for the calculator web service? What's the url? Or do I have to do something extra to register that as a service first?

Best Answer

Looks like it would be http://localhost:8080/bridge/services/Calculator/add

It seems to expect to parameters but there's no indication of how to pass them in the url - you could try appending ?x=2&y=3 to it and see if it returns 5

UPDATE: Yup that seems right, see the post at http://blog.saminda.org/2008/08/exposing-osgi-service-as-web-service.html for a calculator example

UPDATE 2: As I've commented on the original question, the links to the code which you are calling are no longer available. However, it seems like there is a general principle to calling this things. The format seems to be

http://server:port/bridge/services/ClassName/MethodName?parameter=value&anotherparam=value

so in the adding numbers example, ClassName is Calculator, MethodName is add and the x and y parameters (that the code adds together) are passed as URL parameters.

I'm not a Java developer myself, so I don't know if you need to compile the web service code first before it is callable, but if you've got the "hello" code working already, you'll know the answer to this.