java - Retrieving response message from WebService -
in netbeans have use following code:
public string launchrequest(string paramstring) { url localurl = new url(paramstring); object localobject1 = new socket(localurl.gethost(), localurl.getport()); object localobject2 = "get " + paramstring + " http/1.0"; localobject2 = (string)localobject2 + "\r\naccept value: */*\r\n"; localobject2 = (string)localobject2 + "host value: " + localurl.gethost() + ":" + localurl.getport() + "\r\n"; object localobject3 = new printwriter(((socket)localobject1).getoutputstream(), true); ((printwriter)localobject3).println((string)localobject2); ((printwriter)localobject3).close(); ((socket)localobject1).close(); return "ok";} this code supposed call webservice created in c# makes insert operation in oracle database.
url passed looks this:
http://192.168.88.29:443/radupestrea/services/ort.asmx/ortrequest?callbackdisabled=true&siren=328812656&capid=1325369
problem webservice not called. getoutputstream() retuns outputstream has no message webservice. part of webservice:
namespace services { /// /// summary description service1. /// public class ort : system.web.services.webservice { [webmethod] public string ortrequest(bool callbackdisabled, int siren, int capid) { try{ ....... return "success reqid :" + reqnum; catch(exception ex) { return ex.tostring(); } } }
problem cannot modify code. hope problem url sent.
appreciated. thank you.
edit: agreed not beautiful code. task is, java code needs call webservice url link. link supposed make insert in database. there no new record in database. use return statements webservice make sure called nothing returned. may doing wrong, there anyway check webservice has been called ?
if use following code, web service called , new record inserted in database.
<code> localurl = new url(paramstring); localobject1 = ""; localobject2 = localurl.openstream(); localobject3 = new inputstreamreader((inputstream)localobject2); bufferedreader localbufferedreader = new bufferedreader((reader)localobject3); string str1; while ((str1 = localbufferedreader.readline()) != null) { string str2 = ""; localobject1 = (string)localobject1 + str2; } return (string)localobject1; </code>
the problem webservice not called.
you haven't provided evidence effect, , impossible tell code you've posted.
the getoutputstream() retuns outputstream has no message webservice.
this meaningless. outputstreams don't contain messages peer. used send messages to peer. statement , title nonsensical.
is there anyway check webservice has been called successfully?
yes. read response, , return it, instead of hardwiring "ok".
and you've posted code that.
agreed not beautiful code.
it isn't correct code. http headers invalid, , makes no attempt read response. it's incompetent. use httpurlconnection code posted.
Comments
Post a Comment