Hi all,
I want to call some web URL from java application.
When I use "HttpUrlConnection", I get an "OK" responce message. But the target webserver is NOT processing the request appropriately. (I can not check the code in the target app)
I mean,
If u use the same URL straight in the browser, It is working fine as expected.
is there any header prop, etc... or anything else need to be set in for the HttpUrlConnection class.
(Additional question:How to provide the proxy user_name and pass_word for the UrlConn ??)
Fowwing the URL and the code
++++++++++++++++++++++++++++++
import java.net.*;
import java.io.*;
public class HttpTest
{
public static void main (String[] s)
{
try{
URL url = new URL("http://www.m1.com.sg/msgcenter/handphone/msg.cgi?type=handphone&pno=12345678&msg=testmsg");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.usingProxy();
java.util.Properties props = System.getProperties();
props.put("http.useProxy", "true");
props.put("http.proxyHost", "33.33.3.3");
props.put("http.proxyPort", "8080");
connection.connect();
System.out.println("\n Responce Msg: "+connection.getResponseMessage() );
System.out.println("\n M1 Server Date: "+connection.getDate());
System.out.println("\n Local Sys Date: "+System.currentTimeMillis());
connection.disconnect();
}catch(Exception e){e.printStackTrace();}
}
}