黑莓HTTP连接问题 [英] Blackberry HTTP Connection Issue

查看:174
本文介绍了黑莓HTTP连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序编写的插口连接到Web服务(宁静)。该应用程序工作正常的BlackBerry模拟器但是我使用它在黑莓9300有问题。

我不断收到错误。java.io.IOException异常:隧道下当应用程序试图调用Web服务

我打电话的服务是一个简单的HTTP POST和我试图通过WiFi运行这个(WIFI连接为浏览互联网工作的罚款)。

我使用http://127.0.0.1:8080/test/restws;interface=wifi的连接字符串与IP地址改为我打电话的服务器的实际IP地址。我可以调用这个服务器上的RESTful Web服务我的笔记本电脑浏览器的罚款。

在code即时通讯使用类似于下面&安培;在模拟器上正常工作。唯一的IM模拟器和手机上的code之间变化的是(用界面= wifi的为反对是deviceside =真)

连接字符串

这是一个code问题,或者是我需​​要更改手机设置?我需要什么任何想法做克服这一点。

感谢

 的StreamConnection S =(的StreamConnection)连接器
        。开(的connectionString);
    httpConn =(HttpConnection的)S;
    httpConn.setRequestMethod(POST);
    httpConn.setRequestProperty(内容长度,Integer.toString(postData.length()));    OutputStream的输出= httpConn.openOutputStream();
    output.write(postData.getBytes());
    output.flush();
    output.close();    串响应= httpConn.getResponseMessage();
    INT状态code = httpConn.getResponse code();
    如果(状态code!= HttpConnection.HTTP_OK){
    }    InputStream为= httpConn.openInputStream();
    INT RET = 0;
    而((保留= is.​​read(BUF))大于0){
    os.write(BUF,0,RET);
    }    结果=新的String(os.toByteArray());


解决方案

我在这里问题。经过越来越HttpConnection的一切都同我猜。试试这个:

 连接工厂CF =新的ConnectionFactory();
ConnectionDescriptor CD = cf.getConnection(yourURL的);
httpConnector =(HttpConnection的)cd.getConnection();
httpConnector.setRequestMethod(HttpConnection.POST);

I have a simple app written the connects to web service (restful). The app works fine on the blackberry simulator however I'm having problems using it on a blackberry 9300.

I keep getting the error "java.io.ioexception: tunnel down" when the apps attempts to call the web service.

The service I am calling is a simple HTTP post and I'm trying to run this over WIFI (the WIFI connection is working fine for browsing the internet).

I'm using a connection string of "http://127.0.0.1:8080/test/restws;interface=wifi" with the IP address changed to the actual Ip address of the server I'm calling. I can call the restful web service on this server on my laptop browser fine.

The code Im using is similar to below & works fine on the simulator. The only thing im changing between the simulator and the code on the phone is the connection string (using "interface=wifi" as oppose to "deviceside=true")

Is this a code problem or is it a setting I need to change on the handset? Any ideas on what I need to do to overcome this.

Thanks

    StreamConnection s = (StreamConnection) Connector
        .open(connectionString);
    httpConn = (HttpConnection) s;
    httpConn.setRequestMethod("POST");
    httpConn.setRequestProperty("Content-Length", Integer.toString(postData.length()));

    OutputStream output = httpConn.openOutputStream();
    output.write(postData.getBytes());
    output.flush();
    output.close();

    String response = httpConn.getResponseMessage();
    int statusCode = httpConn.getResponseCode();
    if (statusCode != HttpConnection.HTTP_OK) {
    }

    InputStream is = httpConn.openInputStream();
    int ret = 0;
    while ((ret = is.read(buf)) > 0) {
    os.write(buf, 0, ret);
    }

    result = new String(os.toByteArray());

解决方案

I had problems in here .After getting HttpConnection everything is the same i guess. Try this:

ConnectionFactory cf = new ConnectionFactory();
ConnectionDescriptor cd = cf.getConnection("YourUrl");
httpConnector = (HttpConnection) cd.getConnection();
httpConnector.setRequestMethod(HttpConnection.POST);

这篇关于黑莓HTTP连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆