-1

代码:

            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);

日志猫:

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

从服务器端获取数据时出现此错误。我不知道那有什么问题。因为当我使用另一个网络服务时,我的代码运行良好,当我更改我的网络服务时,它给了我这个错误。主要是该网络服务的链接在浏览器中有效,但不适用于 Android 设备。它总是抛出这个错误。请帮助我摆脱这个问题。

4

4 回答 4

3

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

于 2013-09-04T05:43:57.383 回答
2

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

于 2018-01-22T04:44:13.680 回答
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();
    }

字符串.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>
于 2013-08-16T07:18:42.617 回答
0

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

envelope = new SoapSerializationEnvelope (SoapEnvelope.VER12); 

它奏效了,

于 2017-10-30T23:28:10.100 回答