Reputation: 5869
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.
Upvotes: 1
Views: 169
Reputation: 4158
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());
}
Upvotes: 3
Reputation: 2862
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..
http://randywestergren.com/?p=191
Upvotes: 2