apache - Call a java web service method from java client (HTTPPost) -


i want execute method define in java web service java client. using apache tomcat7 host web service locally. using httppost method think using wrong url. following code web service:

public class service{     @post     @path("/getstring")     public string getstring(){         string str = "hello";         return str;     } } 

following client code calling method:

public class client{     public static void main(string[] args) throws exception{         defaulthttpclient httpclient = new defaulthttpclient();         httppost post = new httppost("http://localhost:8080/webservice/getstring");         post.setheadder("content-type", "application/xml");         httpresponse httpres = client.execute(post);         httpentity entity = httpres.getentity();         system.out.println("http response:" + entityutils.tostring(entity));     } } 

the response of client 404 requested resource "webservice/getstring" not found.

please tell me should mention method name in client? have mentioned in url "webservice/getstring" , have mentioned @path annotation. why not getting method getstring() in web service? please help... in advance...


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -