Java 在Blackberry应用程序中集成Post Web服务
我是一名非常新的黑莓应用程序开发人员,在我的黑莓应用程序中集成Web服务时面临一个大问题。我不得不在应用程序中使用Post Web服务,甚至找不到一个教程来解释如何在Blackberry中集成Web服务。在这方面,请有人帮忙。我执行了这个例子。当我尝试打开链接浏览器时,互联网可用,但它没有通过我的应用程序连接到Web服务。在发布之前,请使用“Blackberry+httppost”进行谷歌搜索,您将获得大量链接。 我还为你推荐了一个对初学者有用的链接。听起来不错 您还必须研究连接扩展,如“interface=wifi;deviceside=true”等 试试这个-Java 在Blackberry应用程序中集成Post Web服务,java,blackberry,blackberry-simulator,Java,Blackberry,Blackberry Simulator,我是一名非常新的黑莓应用程序开发人员,在我的黑莓应用程序中集成Web服务时面临一个大问题。我不得不在应用程序中使用Post Web服务,甚至找不到一个教程来解释如何在Blackberry中集成Web服务。在这方面,请有人帮忙。我执行了这个例子。当我尝试打开链接浏览器时,互联网可用,但它没有通过我的应用程序连接到Web服务。在发布之前,请使用“Blackberry+httppost”进行谷歌搜索,您将获得大量链接。 我还为你推荐了一个对初学者有用的链接。听起来不错 您还必须研究连接扩展,如“int
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());
}
试试看{
httpURL=”http://google.co.in/";
if((WLANInfo.getWLANState()==WLANInfo.WLAN\u状态\u已连接)
&&放射性信息
.areWAFsSupported(RadioInfo.WAF_WLAN)){
httpURL+=“接口=wifi”;
}else if(TransportInfo.isTransportTypeAvailable(TransportInfo.TRANSPORT\u BIS\u B)和&TransportInfo.HasufficientCoverage(TransportInfo.TRANSPORT\u BIS\u B)){
System.out.println(“BIS连接---------------------------”;
//Holder.connectionInterface=“;deviceside=false;ConnectionType=mds public”;
httpURL+=“deviceside=false;ConnectionType=mds public”;
}
//Dialog.alert(httpURL);
HttpConnection-httpConn;
httpConn=(HttpConnection)Connector.open(httpURL);
setRequestMethod(HttpConnection.POST);
DataOutputStream _outStream=新的DataOutputStream(httpConn.openDataOutputStream());
byte[]请求_body=httpURL.getBytes();
for(int i=0;i
查看此链接可能会帮助您。。。我得到:-有时应用程序错误104未捕获:NullPointerException和一些时间EOFEException。没有必要使用DataOutputStream\u outStream=new DataOutputStream(httpConn.openDataOutputStream())代码>。您只需使用DataOutputStream\u outStream=httpConn.openDataOutputStream()
@Signare我已经尝试了你的代码,我得到了java.io.InterruptedIOException:本地连接在120000后超时。通过看到上面的错误,我们可以看到它无法连接服务器,但不理解它为什么不连接。使用模拟器浏览器打开时,相同的url工作正常。@Signare否,我正在模拟器上测试,并且通过LAN连接到Internet。@Signare非常感谢您的帮助!