0

我的黑莓应用程序有问题。实际上,我开发了一个黑莓聊天应用程序,使用第三方服务器进行即时消息传递以及一些用于 Web 服务调用的代码。

该应用程序在 WIFI 网络上运行良好,但是当我尝试在运营商网络上运行该应用程序时,它显示

服务器认证失败

这是连接字符串的代码:

    public static String getConnectionString() {
    String connectionString = "";

    if (DeviceInfo.isSimulator()) {
    if (USE_MDS_IN_SIMULATOR) {
    connectionString = ";deviceside=false";
    } else {
    connectionString = ";deviceside=true";
    }
    }

    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
    String carrierUid = getCarrierBIBSUid();
    if (carrierUid == null) {
    // Has carrier coverage, but not BIBS. So use the carrier's TCP
    // network
    connectionString = ";deviceside=true";
    } else {
    connectionString = ";deviceside=false;connectionUID=" + carrierUid + ";ConnectionType=mds-public";
    }
    }
    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
    connectionString = ";deviceside=false";
    }
    else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) {
    }
    else {
    connectionString = ";deviceside=true";
    }
    if ((RadioInfo.getActiveWAFs() & RadioInfo.WAF_WLAN) != 0
    && WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
    connectionString += ";interface=wifi";
    }
    connectionString += ";ConnectionTimeout=30000";
    return connectionString;
    }

这是获取BIS 运营商的代码:

public static String getCarrierBIBSUid() {
    ServiceRecord[] records = ServiceBook.getSB().getRecords();
    int currentRecord;
    try{
    for (currentRecord = 0; currentRecord < records.length; currentRecord++) {
    if (records[currentRecord].getCid().toLowerCase().equals("ippp")) {
    if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) {
    return records[currentRecord].getUid();
    }
    }
    }
}catch (Exception e) {
}
return null;
}
4

1 回答 1

2

您可能没有正确的 BIS 后缀。看看代码有多棘手。有很多事情要考虑,很容易犯错误。这就是 5.0 之前的工作方式。

幸运的是,现在我们有了ConnectionFactory,这让事情变得容易多了。

于 2013-01-14T08:39:05.633 回答