org.xmlpull.v1.XmlPullParserException:意外的标记(位置:TEXT CONS_REF | BILL_MT ...在java.io.InputStreamReader@41222188中为@ 691:1)

时间:2013-12-31 05:07:02

标签: android web-services http ksoap

我开发了一个Android应用程序,我通过它使用.net webservice从网站下载文本文件中的数据。现在,由于我的数据只包含690行,因此到达第691行,它会给出意外的令牌,所以请告诉我应该如何应用检查以跳过空行...我在下面放置的代码以及Logcat

   public static String invokeHelloWorldWS(String name, String webMethName) {
    String resTxt = null;
    // Create request

    SoapObject request = new SoapObject(NAMESPACE, webMethName);

    // Property which holds input parameters
    PropertyInfo celsiusPI = new PropertyInfo();
    // Set Name
    celsiusPI.setName("name");
    // Set Value
    celsiusPI.setValue(name);
    // Set dataType
    celsiusPI.setType(String.class);
    // Add the property to request object
    //request.addProperty(celsiusPI);
    request.addProperty("Content-Type", "text/xml; charset=utf-8");
    // Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    // Set output SOAP object
    envelope.setOutputSoapObject(request);
    // Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        // Invole web service
        androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
        // Get the response
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        // Assign it to fahren static variable
        resTxt = response.toString();

    } catch (Exception e) {
        e.printStackTrace();
        resTxt = "Error occured";
    } 

    return resTxt;
}

记录猫

          12-31 09:59:48.233: W/System.err(2856):
          org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT 
          CONS_REF|BILL_MT...@691:1 in java.io.InputStreamReader@41222188)
          12-31 09:59:48.293: W/System.err(2856):   at     
          org.kxml2.io.KXmlParser.next(KXmlParser.java:426)
          12-31 09:59:48.453: W/System.err(2856):   at    
          org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
          12-31 09:59:48.483: W/System.err(2856):   at   
          org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:2029)
          12-31 09:59:48.503: W/System.err(2856):   at  
          org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)]
          12-31 09:59:48.523: W/System.err(2856):   at 
          org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
          12-31 09:59:48.653: W/System.err(2856):   at 
          org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
          12-31 09:59:48.693: W/System.err(2856):   at 
          com.prgguru.android.WebService.invokeHelloWorldWS(WebService.java:48)
          12-31 09:59:48.723: W/System.err(2856):   at

1 个答案:

答案 0 :(得分:0)

我搜索了这个问题很多,最后解决了。 这个问题不适用于Android编码,它适用于.Net服务绑定。

在服务器上的.Net Web服务中,我将服务模型更改为下面的代码并且工作正常:

旧:

<basicHttpBinding>
    <binding name="basich" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" messageEncoding="Mtom">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>

  </basicHttpBinding>

新:

<basicHttpBinding>

     <binding name="basich">
    </binding>      
  </basicHttpBinding>