6

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?

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37
Steve
  • 11,831
  • 14
  • 51
  • 63
  • 2
    You might want to add a java tag to your question. Maybe even osgi and axis2 tags if they exist. I don't have enough rep points to retag it yet – Rob Cowell Feb 12 '10 at 09:39
  • The links to the sample code for "hello" and the calculator are no longer available, sadly – Rob Cowell Feb 14 '10 at 10:53

3 Answers3

7

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
  • 1,610
  • 3
  • 18
  • 34
0

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, Android iOS, or Silverlight applications:

https://github.com/ServiceStackApps/LiveDemos

mythz
  • 141,670
  • 29
  • 246
  • 390
  • 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 Feb 14 '10 at 11:15
  • oh yeah didn't see the Java tag, assumed .NET, my bad. – mythz Feb 14 '10 at 11:45
  • 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 Feb 14 '10 at 17:45
0

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
  • 7,067
  • 1
  • 25
  • 29