整合后的网络服务在黑莓应用程序



我是一个非常新的黑莓应用程序开发和面临的一个大问题,在集成Web服务在我的黑莓应用程序。我必须在应用程序中使用Post Web服务,甚至没有找到一个教程,解释如何在黑莓整合Web服务。请在这方面找人帮忙。我执行了这个链接上给出的例子。当我尝试打开链接浏览器时,互联网可用,但它没有通过我的应用程序连接到Web服务。

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());
    }

在发布之前请用google搜索"Blackberry+httppost",你会得到很多链接。另外,我建议一个对初学者有用的链接。听起来不错。

你还必须学习连接扩展,如"interface=wifi;deviceside=true"等。

http://randywestergren.com/?p=191

最新更新