Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

HTTP post

Quote from the previous forums:


Guest: Nalan
HTTP post
Posted: Jul 18, 2008 12:26 PM
 
Hi there,

I am newbie to Blackberry application developement.
I have an url. I want to post this url programmatically.
And want to display the response. My blackberry(8100) have Airtel mobile connection.

How can i implement this programmatically?

I tried http://www.northcubed.com/site/?p=48
But it seems it needs APN settings. But i don't know how to do APN settings for Airtel in india.

Is there any generic way to do this, from just using any internet connection?


PLease advice me on this!

Many thanks in advance!!!



Please advice me on this.


Please contact Airtel for their direct TCP APN settings.  However, these are not required if you are on a BlackBerry Enterprise Server.  The following article describes the different connection routes you can use.

 

What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
skylark
Posts: 19
Registered: ‎07-21-2008
My Device: Not Specified

Re: HTTP post

[ Edited ]

Hello MSohm,

 

I used the second method with following code

 

try {
HttpConnection httpConnection = (HttpConnection)Connector.open("http://wap.google.com; WAPGatewayIP=127.0.0.1;WAPGatewayAPN=rim.net.gprs");
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty("If-Modified-Since", "29 Oct 1999 19:43:31 GMT");
httpConnection.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
httpConnection.setRequestProperty("Content-Language", "en-US");

InputStream inputStream = httpConnection.openInputStream();

int len = (int)httpConnection.getLength();
if (len > 0) {
byte[] data = new byte[len];
int actual = inputStream.read(data);
//process(data);
} else {
int ch;
while ((ch = inputStream.read()) != -1) {
//process((byte)ch);
}
}

}
catch(IOException e) {
Dialog.alert(e.toString());
}
finally {
Dialog.alert("Finally block.");
}

 

by just changing the WAPGatewayAPN=carrier.com.gprs into WAPGatewayAPN=rim.net.gprs

 

 

But I am getting java.io.IOException:Invalidurl parameter.

 

How can fix this error?

 

Please advice me.

 

I thank you.

 

 

Message Edited by skylark on 07-21-2008 10:11 AM
Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: HTTP post

What BlackBerry model and handheld software version are you testing with?  This can be found under Options, About on the BlackBerry.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
skylark
Posts: 19
Registered: ‎07-21-2008
My Device: Not Specified

Re: HTTP post

Thanks for quick response buddy!

 

It's BlackBerry 8100  wireless Handheld (EDGE) v4.2.0.67(Platform 2.2.20.39)

  

Please use plain text.
Developer
skylark
Posts: 19
Registered: ‎07-21-2008
My Device: Not Specified

Re: HTTP post

When i am taking off space between http://wap.google.com; and  WAPGatewayIP=127.0.0.1; it says

 

net.rim.device.cldc.io.wahttp.WAPIOException  

 

And please let me know, if you need any further details from me.

 

I thank you. 

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: HTTP post

There shouldn't be any spaces in the URL.  Parameters are separated by semi-colons ';', spaces should not be entered.  Please verify the WAP parameters you are using with your carrier.

 

Mark

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
skylark
Posts: 19
Registered: ‎07-21-2008
My Device: Not Specified

Re: HTTP post

Ok, i will call later today them for the correct parameters.

 

How can i make this working as a general one which will be working for all irrespective of carriers?

 

Thanks!!! 

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: HTTP post

[ Edited ]
WAP Gateway parameters are unique for each carrier.  You'll need to use the parameters for the user's carrier.  There isn't a catch all set of parameters that you can use for WAP gateway connections.
Message Edited by MSohm on 07-21-2008 11:19 AM
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
skylark
Posts: 19
Registered: ‎07-21-2008
My Device: Not Specified

Re: HTTP post

Yes, i can understand that.

 

But how can i make an application which should be working for all users having different carriers?

 

Which one of the three way of making httpconnection will suit for that purpose?

 

Please advice me.

 

Thanks!!! 

 

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: HTTP post

If the user's are on a BlackBerry Enterprise Server, you can make a connection using its Mobile Data Service.  This won't require any carrier specific information.

 

The other alternative is a direct TCP connection.  This requires the user to have entered their carrier's information under Options, TCP.  Or you application can provide this information, but then you are in the same state you are now with the WAP gateway.

 

How To - Specify APN information for a direct TCP connection 
Article Number: DB-00532

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.