This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I'm trying to invoke a RESTful web service using Http GET. The URI, I'm trying to access is "http://server/<somename.aspx>?Action=add". But the code fails with the following error
"ERROR Loading adapter xmls: Object reference not set to an instance of an object."
Below is the sample code.
URL url = new URL("http://server/<somename.aspx>?Action=add");
connection = (HttpURLConnection)url.openConnection();
InputStream ins = connection.getInputStream();
byte buffer = new byte;
sb = new StringBuffer();
while((read = ins.read(buffer))!= -1)
sb.append(new String(buffer, 0, read));
The same code was able to run, if I did not have the query string in my URL. Can you tell me what I'm doing wrong.