XmlpullparserException:期望带引号的String(位置:java.io.Inputstreamreader中的DOCDECL @ 1:62)

时间:2013-08-16 06:49:15

标签: android web-services

代码:

            SoapObject request = new SoapObject(NAMESPACE, SOAP_METHOD_GETDATATBL);

            request.addProperty("TName", ttnm);
            request.addProperty("ColumnNameStr", "*");

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);

            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE aht = new HttpTransportSE(URL1, 60000);
            aht.call(SOAP_ACTION_GETDATATBL, envelope);

            SoapObject response = (SoapObject) envelope.bodyIn;
            System.out.println("Response : " + response);

logcat的:

08-16 12:33:11.000: W/System.err(30741): org.xmlpull.v1.XmlPullParserException: Expected a quoted string (position:DOCDECL @1:62 in java.io.InputStreamReader@40912548) 
08-16 12:33:11.000: W/System.err(30741):    at org.kxml2.io.KXmlParser.readQuotedId(KXmlParser.java:664)
08-16 12:33:11.000: W/System.err(30741):    at org.kxml2.io.KXmlParser.readExternalId(KXmlParser.java:643)
08-16 12:33:11.000: W/System.err(30741):    at org.kxml2.io.KXmlParser.readDoctype(KXmlParser.java:585)
08-16 12:33:11.010: W/System.err(30741):    at org.kxml2.io.KXmlParser.next(KXmlParser.java:418)
08-16 12:33:11.010: W/System.err(30741):    at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
08-16 12:33:11.010: W/System.err(30741):    at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:2029)
08-16 12:33:11.010: W/System.err(30741):    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
08-16 12:33:11.010: W/System.err(30741):    at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
08-16 12:33:11.010: W/System.err(30741):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
08-16 12:33:11.010: W/System.err(30741):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
08-16 12:33:11.010: W/System.err(30741):    at com.example.CommanDatabase.Parsing.getlogindata(Parsing.java:117)
08-16 12:33:11.010: W/System.err(30741):    at com.example.orecs.OrecsSlapeMain$LoginAsyncTask.doInBackground(OrecsSlapeMain.java:1333)
08-16 12:33:11.010: W/System.err(30741):    at com.example.orecs.OrecsSlapeMain$LoginAsyncTask.doInBackground(OrecsSlapeMain.java:1)
08-16 12:33:11.010: W/System.err(30741):    at android.os.AsyncTask$2.call(AsyncTask.java:252)
08-16 12:33:11.010: W/System.err(30741):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-16 12:34:34.870: I/System.out(30927): Login Dailog Call

当我从服务器端获取数据时出现此错误。我不知道那是什么问题。因为当我使用其他Web服务时,我的代码运行良好,当我更改我的Web服务时,它会给我这个错误。主要的是这个Web服务的链接在浏览器中工作,但不适用于Android设备。它总是抛出这个错误。请帮我解决这个问题。

4 个答案:

答案 0 :(得分:2)

问题在于互联网安全..由于在互联网或代理中设置防火墙,我无法连接服务器端的网络服务。

答案 1 :(得分:0)

尝试以下代码..

    HttpTransportSE transporter;
    SoapSerializationEnvelope envelope;
    SoapObject mSoapObject = null;
    String METHOD_NAME = getString(R.string.soap_method_authentication);
    try {

        mSoapObject = new SoapObject(getString(R.string.soap_namespace),METHOD_NAME);
        mSoapObject.addProperty("TName", "test");
        mSoapObject.addProperty("ColumnNameStr", "*");


        transporter = new HttpTransportSE(getString(R.string.soap_main_url));
        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(mSoapObject);
        transporter.call(getString(R.string.soap_namespace) + METHOD_NAME, envelope);


        SoapObject response = (SoapObject) envelope.bodyIn;
        System.out.println("Response : " + response);

    } catch (Exception e) {
        mTextView.setText("Error...");
        e.printStackTrace();
    }

<强> String.xml

<string name="soap_main_url">your_main_url</string>
<string name="soap_namespace">http://tempuri.org/GetDataTbl/</string>
<string name="soap_method_authentication">GetDataTbl</string>

答案 2 :(得分:0)

类似的事情发生在我身上,使用

envelope = new SoapSerializationEnvelope (SoapEnvelope.VER12); 

它有效,

答案 3 :(得分:0)

在我的情况下,由于URL从http更改为https而导致错误。因此,您可能希望确保在处理响应之前获得响应代码200。