XmlPullParserException:期望值START_TAG< ...定义 [英] XmlPullParserException: expected: START_TAG <...definitions

查看:233
本文介绍了XmlPullParserException:期望值START_TAG< ...定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 WSDL 我的 PHP创建(Yii的)Web服务调用连接到Android。但我得到

This is the WSDL I created for php (Yii) web service call to connect to android. But I get

10-19 11:17:36.068: W/System.err(11165): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions name='StatisticController' targetNamespace='http://example.com/webservice/statistic/'>@13:91 in java.io.InputStreamReader@40539de0) 

XML:

<wsdl:definitions name="StatisticController" targetNamespace="http://example.com/webservice/statistic/">
  <wsdl:message name="getGeneralstatRequest"/>
  <wsdl:message name="getGeneralstatResponse">
     <wsdl:part name="return" type="xsd:struct"/>
  </wsdl:message>
  <wsdl:portType name="StatisticControllerPortType">
     <wsdl:operation name="getGeneralstat">
       <wsdl:documentation/>
       <wsdl:input message="tns:getGeneralstatRequest"/>
       <wsdl:output message="tns:getGeneralstatResponse"/>
     </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="StatisticControllerBinding" type="tns:StatisticControllerPortType">
     <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
     <wsdl:operation name="getGeneralstat">
        <soap:operation soapAction="http://example.com/webservice/statistic/getGeneralstat" style="rpc"/>
        <wsdl:input>
           <soap:body use="encoded" namespace="http://example.com/webservice/statistic/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </wsdl:input>
        <wsdl:output>
           <soap:body use="encoded" namespace="http://example.com/webservice/statistic/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </wsdl:output>
     </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="StatisticControllerService">
      <wsdl:port name="StatisticControllerPort" binding="tns:StatisticControllerBinding">
          <soap:address location="http://example.com/webservice/statistic/ws/1"/>
      </wsdl:port>
   </wsdl:service>

Webservice的工作。我测试过的 http://www.validwsdl.com/

Webservice is working. I tested with http://www.validwsdl.com/

Java的code:

Java code:

    private static String domain_name = URLEncoder.encode("example.com");
    private static final String METHOD_NAME = "getGeneralstat";
    private static final String NAMESPACE = "http://"+ domain_name +"/webservice/statistic/";
    //private static final String URL = "http://"+ domain_name +"/webservice/statistic/";
    private static final String URL = "http://"+ domain_name +"/webservice/generalstat2.wsdl";
   private static final String SOAP_ACTION = NAMESPACE + METHOD_NAME;
...
   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
   SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
   envelope.setOutputSoapObject(request);
   HttpTransportSE ht = new HttpTransportSE(URL,8000); // trying 8 sec  
   try {    
     ht.debug = true;
     ht.call(SOAP_ACTION, envelope);
...
   } catch ...
   } catch ...
   } catch (XmlPullParserException xe) {
   } catch ...

我已经尝试了3周,但它不工作。我读过很多很多的话题,但没有解决我的问题。

I've been trying for 3 weeks, but it's not working. I've read many many topics, but nothing resolved my problem.

推荐答案

该XMLParserException可以得到两个点抛出。

The XMLParserException could get thrown at two points.


  1. 当库试图调用之前产生SoapObject

  2. 通话,当响应对象是不是有效的XML(例如,你可以得到结果后
    与服务器错误HTML响应)

调试Web服务调用,并检查您HTTPTransportSE对象的转储变量来看看你的XML是有效的。您也可以复制粘贴转储变量的内容转换成的soapUI来检查,你的XML部分都没有工作。

Debug your Webservice call and check the dump variables of your HTTPTransportSE Object to find out if your XML is valid. You also can copy paste the content of the dump variables into soapUI to check which of your xml parts are not working.

这帮助了我很多 http://mspmsp.brinkster.net/MobileJava/ch16.htm

我希望它能帮助。

这篇关于XmlPullParserException:期望值START_TAG&LT; ...定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆