views:

332

answers:

3

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?

+2  A: 

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.

Rob Cowell
A: 

Well if you have just starting out developing with web-services then you should look at servicestack.net it's an open source web service framework that reduces the learning curve in creating and consuming web services, here is a 'live example' showing you all the source code required to create and call simple web services from an Ajax or Silverlight application:

http://www.servicestack.net/ServiceStack.Examples.Clients/Default.htm

mythz
Looks useful for me (bookmarking that!), but it claims to be for .Net and Mono, whereas original poster is using a framework that seems to be Java based (Apache TomCat).
Rob Cowell
oh yeah didn't see the Java tag, assumed .NET, my bad.
mythz
That's ok, its not tagged java as such, but the underlying platform is java based. The servicestack stuff is still a useful link for me, anyways ;-)
Rob Cowell
A: 

I think it'll be - http://localhost:8080/bridge/services/Calculator/add?x=10&y=10
If you are starting with Java Web Services, do read the book "SOA Using Java Web Services", for details see http://www.soabook.com

Padmarag