How to call method from URL (browser) using webservice in java?

Bhavesh Shah picture Bhavesh Shah · May 31, 2012 · Viewed 12.4k times · Source

I am new to web project. So I am learning new things related to it. Yesterday I ask question about how to call method as below. Actually I have a webservice having one WADL file in it. Can I create the object of the class which is running on JBOSS server?

From that I got one reply that u use wadl2java tool which will consume your Application.wadl file and generate java stubs. You can use these generated java classes to invoke the methods on the object deployed in JBoss server.

Accordingly I generate Java Stub which is interface from WADL using wadl2java. But now I want to access the methods from URL of browser. How can I call it?

I have tried in this way.... http://localhost:8080/prjname/rest/methodName

Is it right way to call method from URL?

Please advice

Thanks

Answer

manurajhada picture manurajhada · May 31, 2012

This is what we call standard URL for web services, there is no automatic generated URLs or fixed or predefined URLs to call them.. you have to define URL structure for your project in codebase, you have to declare base url in your web.xml of project (http://localhost:8080/prjname) and further on your java classes and methods (/rest/methodName) using path annotations.