HTTP Connection Parameters

I am using the HTTP Connection in the following way:

         HttpConnection _httpConnection = null;

         try {
             _httpConnection = (HttpConnection)Connector.open(_url);
         } catch(Exception e) { }

        byte [] postDataBytes = _postData.getBytes();
        _httpConnection.setRequestMethod(HttpConnection.POST);
        _httpConnection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
        _httpConnection.setRequestProperty("Content-Language", "en-US");
        _httpConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
        _httpConnection.setRequestProperty("Connection", "close");
        _httpConnection.setRequestProperty("Content-Length", Integer.toString(_postData.getBytes().length));

        os = _httpConnection.openOutputStream();
        os.write(postDataBytes);
        os.flush();

This HTTP Connection requires parameters to successfully open. For example on a WIFI network, it requires the ";deviceside=true;interface=wifi" to be added to the URL.

The problem is for the EDGE connection. Each country requires different parameters to be added. For example in lebanon it requires ";deviceside=false" but in KSA if i add this parameter the connection will not open. In USA it needs different types of parametes. The question is how to establish an HTTP connection for all the countries with the same parameters. So that the application will successfully have an internet connection no matter where it is downloaded.

Anyone can help with this problem? Thanks in advance

Answers


Welcome to the confusing world of network transports on BlackBerry! You will want to start with the article Connecting your BlackBerry - http and socket connections to the world.

Here is a simple example for "just give me a connection" (note, you will need to add appropriate error handling; also, myURL in the code below should have no connection descriptor info appended to it):

ConnectionFactory factory = new ConnectionFactory();
ConnectionDescriptor descriptor = factory.getConnection(myURL);
if (descriptor != null) {
    _httpConnection = (HttpConnection) descriptor.getConnection();
    ...
}

Try using to use the method reffered in this link melick-rajee.blogspot.com and use it like

_url = "http://www.example.com";

_httpConnection = (HttpConnection)Connector.open(_url + getConnectionString());

You will have to sign the application to use this else the application will show exception. To sign your application just go here Code Signing Keys


To use the connectionFactory, seems you need to set BisBOptions.

Try this:

    connFact = new ConnectionFactory();
    connFact.setTransportTypeOptions(TransportInfo.TRANSPORT_BIS_B,
                    new BisBOptions("mds-public"));

Need Your Help

python or on operator module

python operators

On the operator module, we have the or_ function, which is the bitwise or (|).

T-Sql - Order By on Alphanumeric

tsql sql-server-2008 sql-order-by alphanumeric

i have a list of alphanumeric tokens, say '1a', '1b', '02', '03', '10', '11', etc...