获取BlackBerry中的SOAP连接的org.xmlpull.v1.XmlPullParserException

时间:2013-05-04 17:32:58

标签: web-services soap blackberry ksoap2

我在我的webservice调用应用程序中使用kso​​ap2.jar。 在连接时,当我使用Wi-Fi或模拟器进行测试时,它会给出以下错误:  org.xmlpull.v1.XmlPullParserException:意外类型(位置:END.OCOMENT null @ 1:0 in java.io.InputStreamReader@6111a1f1)

当我使用SIM卡进行测试时,它会抛出此错误:java.io.InterruptedIOException:〜120000之后本地连接超时

我已为此webservice连接编写了以下代码:

    SoapObject rpc = new SoapObject(serviceNamespace, methodName);
        rpc.addProperty("UserID", "1");
        rpc.addProperty("UserName", "xyz");
        rpc.addProperty("ContactNo", "9014567890");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.bodyOut = rpc;
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.ENC;

        HttpTransport ht = new HttpTransport(serviceUrl + getConnectionString().trim());
        ht.debug = true;
        System.out.println("debug true ------- ");
        ht.setXmlVersionTag(" version=\"1.0\" encoding=\"UTF-8\"?>");
        SoapObject  response = null;
        try
        {
            ht.call(soapAction, envelope);
             response = (SoapObject )envelope.getResponse();
             String resultbody = response.getProperty("updateUserDetailResult").toString();
        }
        catch(org.xmlpull.v1.XmlPullParserException ex2){

            resultLbl.setText(ex2.toString());
        }
        catch(Exception ex){
        String bah = ex.toString();
        resultLbl.setText(bah);
        }




/**
     * Looks through the phone's service book for a carrier provided BIBS network
     * 
     * @return The uid used to connect to that network.
     */
    private static String getCarrierBIBSUid() 
    {
        net.rim.device.api.servicebook.ServiceRecord[] records = ServiceBook.getSB().getRecords();
        int currentRecord;

        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();
                }
            }
        }
        return null;
    }

    /**
     *  Getting the connection string based on the connection
     * @return
     */
    public static String getConnectionString() 
    {
        String connectionString = null;

        // Wifi is the preferred transmission method
        if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) 
        {
            connectionString = ";interface=wifi";

        }
        // Is the carrier network the only way to connect?
        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 
            {
                // otherwise, use the Uid to construct a valid carrier BIBS
                // request

                connectionString = ";deviceside=false;connectionUID=" + carrierUid + ";ConnectionType=";
            }
        }

        // Check for an MDS connection instead (BlackBerry Enterprise Server)
        else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
        {
            connectionString = ";deviceside=false";

        }

        // If there is no connection available abort to avoid bugging the user
        // unnecssarily.
        else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) 
        {

        }

        // In theory, all bases are covered so this shouldn't be reachable.
        else 
        {
            connectionString = ";deviceside=true";
        }

        return connectionString;
    }

我正在使用预先验证的ksoap jar文件(ksoap2-j2me-core-prev-2.1.2.jar)。

我没有准确到达出错的地方。我在论坛上搜索过但没有得到正确的解决方案。

感谢。

0 个答案:

没有答案