BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-02-2007, 12:53 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8700
PIN: N/A
Carrier: AT&T
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Post Data with HTTP Connection!

Please Login to Remove!

Dear folks,

I am developing a client-server application for BlackBerry, the server code was developed in ASP.NET 2.0

When I connect from client by JDE 4.2 and MDS simulator, It is OK. But, when I deploy on my device it can not post data, I think the root cause is the content type of HTTP Connection.

If you have the same problems and solve it, please help me.

Thanks & Regards,
Vien Nguyen


My client code is below:

public static int validateAccount(String blackBerryId) {
HttpConnection httpConection = null;
InputStream is = null;
OutputStream os = null;
String response = "";
try {
httpConection = (HttpConnection) Connector
.open("http://192.168.10.1/BlackBerry/ValidateAccount.aspx");
if (httpConection == null) {
return BBerryConstants.FAILED;
}
httpConection.setRequestMethod(HttpConnection.POST );
httpConection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
httpConection.setRequestProperty("If-Modified-Since",
"29 Oct 1999 19:43:31 GMT");
httpConection.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Configuration/CLDC-1.0");
httpConection.setRequestProperty("Content-Language", "en-US");


os = httpConection.openOutputStream();
BBerryParameter[] params = new BBerryParameter[1];
params[0] = new BBerryParameter("_BlackBerryID", blackBerryId);

String data = CommonUtils.getDataString(params);
StringBuffer buffer = new StringBuffer();

buffer.append(data);
System.out.println("Params " + data);
os.write(buffer.toString().getBytes());
os.flush();

System.out.println("Params " + data);

int rc = httpConection.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
return BBerryConstants.FAILED;
}

is = httpConection.openInputStream();

int len = (int) httpConection.getLength();
if (len > 0) {
int actual = 0;
int bytesread = 0;
byte[] result = new byte[len];
while ((bytesread != len) && (actual != -1)) {
actual = is.read(result, bytesread, len - bytesread);
bytesread += actual;
}
response = new String(result);
}

} catch (Exception e) {

} finally {
try {
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
if (httpConection != null) {
httpConection.close();
}
} catch (Exception e) {
}
}
System.out.println("Respone " + response);
....
return BBerryConstants.FAILED;
}
Offline  
Old 11-02-2007, 11:03 AM   #2 (permalink)
New Member
 
Join Date: Nov 2007
Model: 7130e
PIN: N/A
Carrier: Rogers
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this:
Add ";deviceside=true" at the end of the URL.

httpConection = (HttpConnection) Connector
.open("http://192.168.10.1/BlackBerry/ValidateAccount.aspx;deviceside=true");
Offline  
Old 11-04-2007, 09:10 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8700
PIN: N/A
Carrier: AT&T
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Pray4Mojo,

I already found the root cause of my application. It is not wrong at HTTP connection. The calling HTTP connection must be wrapped into a Thread in an GUI application on Blackberry.

Thanks so much.
Vien Nguyen
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

Turck Proximity Switch BC10-M30-AP4X-H1141
$35.0
Turck Proximity Switch BC10-M30-AP4X-H1141 pictureRainproof Hoist Crane Pendant Pushbutton Switch Station Up-Down DT
$13.43
Rainproof Hoist Crane Pendant Pushbutton Switch Station Up-Down DT picture1Pcs NEW Pepperl+Fuchs NCN15-30GM40-NO-V1 Proximity switch
$92.0
1Pcs NEW Pepperl+Fuchs NCN15-30GM40-NO-V1 Proximity switch pictureRicoh Aficio Ricoh Aficio 1013F Copier Switch and Lever
$11.99
Ricoh Aficio Ricoh Aficio 1013F Copier Switch and Lever pictureIdec Switching Power Supply PS3L-D12AF 100-240VAC 50-60Hz
$74.98
Idec Switching Power Supply PS3L-D12AF 100-240VAC 50-60Hz picture






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