11-20-2009 05:48 AM
Hi all,
I am not ablt to connect to server below is my code
public void IssueHTTPPostL(String name) throws IOException
{
synchronized(this)
{
HttpConnection httpConn = null;
String url = "http://200.196.100.21:8100/test/dbget.jsp;deviceside=true;apn=blackberr y.net;";
InputStream is = null;
InputStream is1 = null;
OutputStream os = null;
try {
httpConn = (HttpConnection)Connector.open(url); //after this line code is not going to execute(i have done debug......)
// Setup HTTP Request to POST
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Accept_Language","en- US");
//Content-Type is must to pass parameters in POST Request
httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpConn.setRequestProperty("imei", "1243242434");
httpConn.setRequestProperty("user", "xxx");
// httpConn.setRequestProperty("name", "abcd");
httpConn.setRequestProperty("password", "dmw");
// httpConn.setRequestProperty("contentType", "Images");
// httpConn.setRequestProperty("task", "retrieve");
os = httpConn.openOutputStream();
String params;
params = "name=" + name;
os.write(params.getBytes());
// Read Response from the Server
StringBuffer sb = new StringBuffer();
is = httpConn.openDataInputStream();
int chr;
while ((chr = is.read()) != -1)
sb.append((char) chr);
System.out.println(sb.toString());
int i = httpConn.getResponseCode();
if (i == HttpConnection.HTTP_OK)
{
System.out.print("HTTP_OK");
}
//form.append(""+i);
//form.append(sb.toString());
//form.append(httpConn.getRequestProperty("name")) ;
} finally {
if(is!= null)
is.close();
if(os != null)
os.close();
if(httpConn != null)
httpConn.close();
}
}
}
11-20-2009 06:07 AM
Are you sure about the APN which you set in the URL is correct respect to the network operator?
11-20-2009 06:15 AM
hi,
thanks for your reply. yes airtel india.it is correct.
11-20-2009 06:23 AM
What exception is thrown?
11-20-2009 06:31 AM
Hi,
it throws IOexception.
thanks for reply once again.
11-20-2009 06:47 AM
Check this thread.
http://supportforums.blackberry.com/t5/Java-Develo
11-20-2009 06:51 AM
I think the issue is caused by you using the wrong APN. Via the "blackberry.net" APN one can usually only access the RIM's network infrastructure -- it's not usually possible to get a direct IP route to the Internet via the "blackberry.net" APN.
11-20-2009 06:57 AM
Right klyubin.
@op - check the thread which I have posted, it has a APN for Airtel.
11-20-2009 07:06 AM - last edited on 11-20-2009 07:22 AM
Hi,
i m still getting ioxception even though i used airtelgprs.com forapn.i have just checked the funambol sync.it show the apn blackberry.net while connecting to their server.why am i getting ioexception.is it my code right ?
thanks,
sunil
11-20-2009 07:18 AM
Use airtelgprs.com for APN