BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-26-2009, 12:39 AM   #1 (permalink)
New Member
 
Join Date: Dec 2008
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in http Connection with setRequestPRoperty()

Please Login to Remove!

Whenever i am using setRequestProperty() in JDE 4.0 it is not working in my application. Giving exception time out. It was working weel in JDE 4.2. Can some one tell me what could be wrong in it ?
__________________
Kartik Trivedi

(Sun Certified Java Developer)

(Forum Nokia Champion)

(Software Developer-J2ME)

(Saltriver Infosystem)
Offline  
Old 03-26-2009, 12:57 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: Ernakulam, Kerala, India
Model: 8320
Carrier: Airtel
Posts: 65
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post

Quote:
Originally Posted by honestsuccess View Post
Whenever i am using setRequestProperty() in JDE 4.0 it is not working in my application. Giving exception time out. It was working weel in JDE 4.2. Can some one tell me what could be wrong in it ?
Please paste the code segment that you used, what are you doing inside it ?
__________________
Regards
Anand.
Offline  
Old 03-26-2009, 01:42 AM   #3 (permalink)
New Member
 
Join Date: Dec 2008
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Ananthasivan V K View Post
Please paste the code segment that you used, what are you doing inside it ?

The following is code. take a look at it and plesae let me know if you find any thing wrong in it.

private String MakeGetRequest(String command)

{

//open the connection and extract the data

StreamConnection s = null;



HttpConnection c = null;

InputStream is = null;

OutputStream os = null;

int rc;



String url = Url() + command;

String credentials = Credentials();



try {

c = (HttpConnection)Connector.open(url);

c.setRequestMethod(HttpConnection.GET);

c.setRequestProperty("Connection", "Keep-Alive");

c.setRequestProperty("User-Agent", "test app");

c.setRequestProperty("Accept", "application/xml");

c.setRequestProperty("Content-Type", "application/xml");

c.setRequestProperty("Authorization", "Basic " + credentials);



os = c.openOutputStream();



// Getting the response code will open the connection,

// send the request, and read the HTTP response headers.

// The headers are stored until requested.

rc = c.getResponseCode();

if (rc != HttpConnection.HTTP_OK) {

throw new IOException("HTTP response code: " + rc);

}



is = c.openInputStream();



// Get the ContentType

String type = c.getType();



// Get the length and process the data

int len2 = (int)c.getLength();

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();



//byte[] buffer = new byte[256];

byte[] buffer = new byte[len2];

is.read(buffer);

byteArrayOutputStream.write(buffer);

/*

int len = 0, imageSize = 0;



while (-1 != (len = is.read(buffer))) {

byteArrayOutputStream.write(buffer);

imageSize += len;

}

*/

byteArrayOutputStream.flush();

String result = byteArrayOutputStream.toString();

byteArrayOutputStream.close();



return result;



} catch (ClassCastException e) {

throw new IllegalArgumentException("Not an HTTP URL");

} catch (IOException e) {

throw new IllegalArgumentException("Not an HTTP URL");

} finally {

}

}
__________________
Kartik Trivedi

(Sun Certified Java Developer)

(Forum Nokia Champion)

(Software Developer-J2ME)

(Saltriver Infosystem)
Offline  
Old 03-26-2009, 06:40 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: Ernakulam, Kerala, India
Model: 8320
Carrier: Airtel
Posts: 65
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Hi

Hi Karthik

I guess some of the property you specified is not correct, Have you tried without specifying those request properties ? Also the Authentication you specified I guess its not the exact way to give the same. Please try a simple request, then go for full fledged one.
__________________
Regards
Anand.
Offline  
Old 03-26-2009, 02:12 PM   #5 (permalink)
New Member
 
Join Date: Dec 2008
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default MDS and http connection

Is there necessary to use MDS ? One person told me that you are getting this exception "
Excepttion-java.io.InterruptedIOException: Local connection timed out after ~ 120000". One person told me that you must use MDS. Am i getting this exception because of that ?
__________________
Kartik Trivedi

(Sun Certified Java Developer)

(Forum Nokia Champion)

(Software Developer-J2ME)

(Saltriver Infosystem)
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

DELL 725-10263 / 331-1310 / KT74N Lamp manufactured by DELL
$208.82
DELL 725-10263 / 331-1310 / KT74N Lamp manufactured by DELL pictureDELL 725-BBBQ Lamp manufactured by DELL
$152.29
DELL 725-BBBQ Lamp manufactured by DELL pictureOEM BULB with Housing for DELL 725-10331 Projector with 180 Day Warranty
$319.0
OEM BULB with Housing for DELL 725-10331 Projector with 180 Day Warranty pictureOEM BULB with Housing for DELL 7700 FullHD Projector with 180 Day Warranty
$319.0
OEM BULB with Housing for DELL 7700 FullHD Projector with 180 Day Warranty pictureOEM BULB with Housing for DELL 725-10323 Projector with 180 Day Warranty
$319.0
OEM BULB with Housing for DELL 725-10323 Projector with 180 Day Warranty picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.