java - Using Http client -
i new web services,but how managed create web service after reading docs. able wsdl file fallowing loaction : //?wsdl. generated wsdl contains methods(api's) , able test same soap ui. need response in browser,so decided use http client fallows:-
httpclient httpclient = new defaulthttpclient();
httpget getrequest = new httpget( "http://<localhost>/<servicename>/getcustomerattributesbyid?customerid=60000"); httpresponse response = httpclient.execute(getrequest); bufferedreader rd = new bufferedreader (new inputstreamreader(response.getentity().getcontent())); string line = ""; while ((line = rd.readline()) != null) { system.out.println("o/p line:"+line); }
but o/p line empty.what might reason.please me.
you can try set timeout on http connection. here sample code.
httpget getrequest = new httpget( "http://<localhost>/<servicename>/getcustomerattributesbyid?customerid=60000"); httpparams httpparameters = new basichttpparams(); int timeout = 50000; httpconnectionparams.setconnectiontimeout(httpparameters, timeout); httpconnectionparams.setsotimeout(httpparameters, timeout); defaulthttpclient httpclient = new defaulthttpclient(httpparameters); httpresponse response = httpclient.execute(getrequest); bufferedreader rd = new bufferedreader (new inputstreamreader(response.getentity().getcontent())); string line = ""; while ((line = rd.readline()) != null) { system.out.println("o/p line:"+line); }
Comments
Post a Comment