Connection HTTP - tried and tried, but I still can't make it work!

I am building this application that needs to get a XML from a web server. I got to work on the Simulator successfully, but were unable to make it work on my 8310. I have read on different transport and used the following code to try and choose the appropriate option.

Simple function to obtain the registration of WAP service.

private ServiceRecord getWAP2ServiceRecord() {
        ServiceBook sb = ServiceBook.getSB();
        ServiceRecord[] records = sb.getRecords();

        for (int i = 0; i < records.length; i++) {
            String cid = records[i].getCid().toLowerCase();
            String uid = records[i].getUid().toLowerCase();
            if (cid.indexOf("wap") != -1 && uid.indexOf("wifi") == -1
                    && uid.indexOf("mms") == -1 && uid.indexOf("browser") == -1
                    && uid.indexOf("push") == -1
            ) {
                return records[i];
            }
        }

        return null;
    }

Conditions used to build the string.

String connectionParameters = "";
            // JDE 4.3 is required to get WLANInfo
            if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
                // Connected to a WiFi access point
                connectionParameters = ";interface=wifi";
            } else {
                int coverageStatus = CoverageInfo.getCoverageStatus();
                ServiceRecord record = getWAP2ServiceRecord();
                if (record != null
                        // In JDE 4.5 CoverageInfo changed the name of COVERAGE_CARRIER to COVERAGE_DIRECT
                        // The constant value for both is the same, '1', so you can use that to avoid any
                        // dependency on JDE 4.5
                        && (coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
                    // Have network coverage and a WAP 2.0 service book record
                    connectionParameters = ";deviceside=true;ConnectionUID="
                            + record.getUid();
                } else if ((coverageStatus & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
                    // Have an MDS service book and network coverage
                    connectionParameters = ";deviceside=false";
                } else if ((coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
                    // Have network coverage but no WAP 2.0 service book record
                    connectionParameters = ";deviceside=true";
                }
            }
            _url += connectionParameters;
            HttpConnection connection = (HttpConnection)Connector.open(_url, Connector.READ_WRITE, true);

I get an error "Failure of Tunnel" when the application is running but I have tried in vain to fix.

Feature: 8310

OS: 4.5.0.182

Carrier: Digicel Jamaica

The logic in the code above was added successfully; deviceside = true; ConnectionUID = secure WAPtrans

I'm ideas here any help would be really appreciated.

Ask a really stupid question, if you look at what he told you to use this article I mentioned in my last Post

How - to specify APN information for a direct TCP connection
Article number: DB-00532

and compare that with what you actually used, did you notice a difference?

May I suggest that read you the two articles again and specify either direct TCP APN values or WAP, not both?  In fact, I'd forget the WAP values, you are better using the code in the article to extract a COnnecitionUID and use the WAP 2.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for