I am very new Blackberry App Development and facing a big problem in integrating Web Services in my Blackberry app. I have to use Post Web Services in the Application and don't find even a single tutorial which explains how to integrate the Web services in Blackberry. Please some one help in this regard. I executed the example give at this link. Internet Avaialble when I try to open link Browser but it is not connecting to Web Services through my App.
Asked
Active
Viewed 168 times
1
-
SEE THIS LINK MAY HELP YOU... http://stackoverflow.com/questions/8969666/http-post-blackberry-null-response/8981963#8981963 – alishaik786 Apr 06 '13 at 11:24
-
I am getting :- Sometimes App Error 104 Uncaught: NullPointerException and Some time EOFException. – P.J Apr 19 '13 at 09:45
2 Answers
3
try this -
try {
httpURL="http://google.co.in/";
if ((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
&& RadioInfo
.areWAFsSupported(RadioInfo.WAF_WLAN)) {
httpURL += ";interface=wifi";
}else if (TransportInfo.isTransportTypeAvailable(TransportInfo.TRANSPORT_BIS_B) && TransportInfo.hasSufficientCoverage(TransportInfo.TRANSPORT_BIS_B)) {
System.out.println("BIS CONNECTION-------------------");
// Holder.connectionInterface=";deviceside=false;ConnectionType=mds-public";
httpURL += ";deviceside=false;ConnectionType=mds-public";
}
//Dialog.alert(httpURL);
HttpConnection httpConn;
httpConn = (HttpConnection) Connector.open(httpURL);
httpConn.setRequestMethod(HttpConnection.POST);
DataOutputStream _outStream = new DataOutputStream(httpConn.openDataOutputStream());
byte[] request_body = httpURL.getBytes();
for (int i = 0; i < request_body.length; i++) {
_outStream.writeByte(request_body[i]);
}
DataInputStream _inputStream = new DataInputStream(
httpConn.openInputStream());
StringBuffer _responseMessage = new StringBuffer();
int ch;
while ((ch = _inputStream.read()) != -1) {
_responseMessage.append((char) ch);
}
String res = (_responseMessage.toString());
responce = res.trim();
//Dialog.alert(responce);
httpConn.close();
}catch (Exception e) {
Dialog.alert("Error -"+e.toString());
}

Rince Thomas
- 4,158
- 5
- 25
- 44
-
It's not necessary to use `DataOutputStream _outStream = new DataOutputStream(httpConn.openDataOutputStream());`. You can just use `DataOutputStream _outStream = httpConn.openDataOutputStream();`. – Nate Apr 19 '13 at 21:28
-
@Signare I have tried your code and I am getting java.io.InterruptedIOException:Local connection timed out after ~120000. By seeing the above error we can under it is unable to connect server but not understanding why its not connecting. The same url when opened using simulators browser works fine. – TNR Apr 22 '13 at 08:20
-
@Signare No, I am testing on Simulator and I have Internet Connectivity through LAN. – TNR Apr 22 '13 at 09:06
-
http://chat.stackoverflow.com/rooms/4014/knowledge-sharing-center-for-blackberry-java – Rince Thomas Apr 22 '13 at 09:37
2
before posting please google with "Blackberry+httppost" you will get lots of links. Also for you i suggest one link which is useful to beginners. It sounds good.
Also you have to study Connection extensions like "interface=wifi;deviceside=true" etc..

Govindarao Kondala
- 2,862
- 17
- 27