BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-11-2006, 12:22 PM   #1
husky
New Member
 
Join Date: Sep 2006
Model: 7100t
Posts: 2
Default HTTP POST body lost

Please Login to Remove!

Hi,

I developed a J2ME application to communicate a JAVA web server by sending and receiving XML messages, first I used MIDP 2.0 /CLDC 1.1, the application runs well on SUN's wireless toolkit's cell phone emulator, can do HTTP POST send back message to the server, when I delopyed the application to BlackBerry's emulator,it just got a deadlock, I set up a proxy server montoring the traffic of the JAVA server, I found out that the blackBerry can not send back the HTTP POST body, but the header is receivd by the server, and of course the MDS is running before the PDA client application started.
I also try use JDE 4.1 to debug this appliction, I checked the logs of the MDS, I even change the source code and only following RIM's programming standard, it still can not send the HTTP POST body back to the server,
Does anyone have the similar experience with me, please share your solutions, thanks a lot!
Offline  
Old 09-11-2006, 01:11 PM   #2
husky
New Member
 
Join Date: Sep 2006
Model: 7100t
Posts: 2
Default source code for http processing

public class HttpHelper {

//do a GET or POST request to a web server
public static String doHttpRequest(String urlString, String postStr)
{
HttpConnection hc = null ;
InputStream is = null;
OutputStream os = null;

String responseString = "";
try {
hc = (HttpConnection) Connector.open(urlString);
if ( postStr != null) {
hc.setRequestMethod(HttpConnection.POST);
hc.setRequestProperty("User-Agent", "BlackBerry/4.1.0");
hc.setRequestProperty("Content-Language", "en-US");

os = hc.openOutputStream();
os.write(postStr.getBytes());
os.flush();

int responseCode = hc.getResponseCode();

if (responseCode != HttpConnection.HTTP_OK) {
System.out.println("HTTP post error!");
return null;
}
}
else {
hc.setRequestMethod(HttpConnection.GET);
}
is = hc.openInputStream();
int ch;
while ((ch = is.read())!= -1){
responseString += (char)ch;
}
}
catch (IOException e) {
System.err.println(e.toString());

}
finally {
try {
if (os != null) os.close();
if (is != null) is.close();
if (hc != null) hc.close();
}
catch (IOException ioe){}
}
return responseString;
}

}
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Siemens 6SL3130-6AE21-0AB1 Smart Line Module 6SL3 130-6AE21-0AB1 Express Ship picture

Siemens 6SL3130-6AE21-0AB1 Smart Line Module 6SL3 130-6AE21-0AB1 Express Ship

$999.00



New Factory Sealed SIEMENS 6SL3210-1KE15-8UF2 6SL3 210-1KE15-8UF2 In Box picture

New Factory Sealed SIEMENS 6SL3210-1KE15-8UF2 6SL3 210-1KE15-8UF2 In Box

$850.20



Siemens 6SL3310-1TE32-1AA0 Brand New 6SL3310-1TE32-1AA0 DHL Express shipping picture

Siemens 6SL3310-1TE32-1AA0 Brand New 6SL3310-1TE32-1AA0 DHL Express shipping

$14000.00



1PCS NEW 6SL3120-1TE32-0AA4 Siemens PLC Module Expedited Shipping Factory Sealed picture

1PCS NEW 6SL3120-1TE32-0AA4 Siemens PLC Module Expedited Shipping Factory Sealed

$4998.00



LOT OF 10 SIEMENS Q120DFN 20A DUAL AFCI/GFCI PLUG ON NEUTRAL BREAKER BRAND NEW picture

LOT OF 10 SIEMENS Q120DFN 20A DUAL AFCI/GFCI PLUG ON NEUTRAL BREAKER BRAND NEW

$448.99



LOT OF 10 SIEMENS QA120AFC  20A AFCI BREAKER (with pigtail wire) NEW picture

LOT OF 10 SIEMENS QA120AFC 20A AFCI BREAKER (with pigtail wire) NEW

$398.99







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