English 中文(简体)
正在建立联系,但内容无法从网络服务中检索。
原标题:Connection being made, but content is unable to be retrieved from web service
  • 时间:2012-01-14 22:45:27
  •  标签:
  • blackberry
public class ConsumeFactoryThread extends Thread {
    private String url;
    private HttpConnection httpConn;
    private InputStream is;
    private CustomMainScreen m;
    private JSONArray array;

    public ConsumeFactoryThread(String url, CustomMainScreen m){
        System.out.println("Connection begin!");
        this.url = url;
        this.m = m;
    }

    public void finished(){
        m.onFinish(array);


    }

    public void run(){

        myConnectionFactory connFact = new myConnectionFactory();
        ConnectionDescriptor connDesc;

        connDesc = connFact.getConnection(url);
        System.out.println("Connection factory!");
        if(connDesc != null)
        {
            System.out.println("Connection not null!");
            httpConn = (HttpConnection) connDesc.getConnection();
            is = null;



            try
            {
                final int iResponseCode = httpConn.getResponseCode();
                UiApplication.getUiApplication().invokeLater(new Runnable()
                {

                    public void run()
                    {
                        System.out.println("Connection in run!");
                         // Get InputConnection and read the server s response
                        InputConnection inputConn = (InputConnection) httpConn;
                        try {
                            is = inputConn.openInputStream();
                            System.out.println("Connection got inputstream!");
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        byte[] data = null;
                        try {
                            data = IOUtilities.streamToBytes(is);
                            System.out.println("Connection got data!");
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }



                        String result = new String(data);
                        System.out.println("Connection Data: "+result);
                        try {
                            array = new JSONArray(result);

                            //finished();

                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }


                    }

                });
            }
            catch(IOException e)
            {
                System.err.println("Caught IOException: " + e.getMessage());
            }
        }

    }

}

I m using the blackberry torch 9800 simulator and hardware device for testing. In the simulator I cannot retrieve the data over wifi, even though the connection to wifi is found. It works when the mobile network is enabled.

现在,当我用Twitter的复印机取代我的网络服务时,我获得数据,不管运输类型如何。 我尝试增加;我只字不提。 它不是指任何。

我只想利用我的网络服务! 我不知道这种 m、bis、bis、bis。

EDIT:

Jeez. I m realizing it may be my site. Not using the web service and just retrieving the page, www.example.com, I get nothing. But, google.com or any other site I use retrieves the html. Am I missing headers!?!

问题回答

传真;interface=wifi 至URL结束,这将迫使模拟器使用你模拟的Wi-Fi链接,即你的PC网络连接。

您将需要在模拟器上安装Wi-Fi,然后将安装在<代码>上。 ExecutiveeLinks->Set Up Wi-Fi Network, 然后与连接。 Default WLAN Network





相关问题
How does AlertListener work on Blackberry API 5.0?

Does the AlertListener interface works globally on all alerts on the blackberry device, or does it only work with alerts generated by your application? In other words, can I use this interface to ...

How to buffer audio in Blackberry?

I need to learn how to buffer audio stream from a remote server in Blackberry. There is a sample buffered playback app with Blackberry api but can you tell what url may I use to test the application?

Blackberry push notification implementation

How does one implement a push notification for a blackberry app? I heard that in order to do so I need to purchase a Blackberry Enterprise Server which costs me 1400 per year. Is this true? Where is ...

热门标签