1

我将 ksoap2 用于 android web 服务,但出现以下错误:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG

这是 wsdl 文件:“meteo.wsdl”

<?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions xmlns:sch="http://www.tunisiana.com/samples/schemas/messages" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.tunisiana.com/samples/schemas/messages" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.tunisiana.com/samples/schemas/messages">
- <wsdl:types>
- <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.tunisiana.com/samples/schemas/messages" xmlns:tns="http://www.tunisiana.com/samples/schemas/messages">
- <element name="Horoscope">
- <complexType>
- <all>
  <element name="signe" type="string" /> 
  <element name="ordre" type="int" /> 
  <element name="amour" type="string" /> 
  <element name="sante" type="string" /> 
  <element name="travail" type="string" /> 
  <element name="date" type="string" /> 
  <element name="image" type="base64Binary" /> 
  </all>
  </complexType>
  </element>

<simpleType name="OrdreSigne">
- <restriction base="int">
  <minInclusive value="1" /> 
  <maxInclusive value="12" /> 
  </restriction>
  </simpleType>
- <element name="GetHoroscopeJourRequest">
- <complexType>
- <sequence>
  <element name="ordre_signe" type="tns:OrdreSigne" /> 
  </sequence>
  </complexType>
  </element>
- <element name="GetHoroscopeJourResponse">
- <complexType>
- <sequence>
  <element ref="tns:Horoscope" /> 
  </sequence>
  </complexType>
  </element>
</schema>
</wsdl:types>

<wsdl:message name="GetHoroscopeJourRequest">
  <wsdl:part element="tns:GetHoroscopeJourRequest" name="GetHoroscopeJourRequest" /> 
  </wsdl:message>

<wsdl:message name="GetHoroscopeJourResponse">
  <wsdl:part element="tns:GetHoroscopeJourResponse" name="GetHoroscopeJourResponse" /> 
  </wsdl:message>
<wsdl:operation name="GetHoroscopeJour">
  <wsdl:input message="tns:GetHoroscopeJourRequest" name="GetHoroscopeJourRequest" /> 
  <wsdl:output message="tns:GetHoroscopeJourResponse" name="GetHoroscopeJourResponse" /> 
  </wsdl:operation>
<wsdl:binding name="MeteoSoap11" type="tns:Meteo">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
 <wsdl:operation name="GetHoroscopeJour">
  <soap:operation soapAction="" /> 
- <wsdl:input name="GetHoroscopeJourRequest">
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output name="GetHoroscopeJourResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
 </wsdl:binding>

<wsdl:service name="MeteoService">
- <wsdl:port binding="tns:MeteoSoap11" name="MeteoSoap11">
  <soap:address location="http://localhost:8080/Contenu20/services" /> 
  </wsdl:port>
  </wsdl:service>
 </wsdl:definitions>

Horoscopefetcher.java

public class HoroscopeFetcher {

    private final String NAMESPACE = "http://www.tunisiana.com/samples/schemas/messages/";
    private final String METHOD_NAME = "GetHoroscopeJour";
    private final String SOAP_ACTION = ""; 
    private final String URL = "http://172.24.1.47:8080/Contenu20/meteo.wsdl";


    private final SoapSerializationEnvelope envelope;

    public HoroscopeFetcher(int ordre)
    {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);        

        request.addProperty("ordre_signe",ordre);

        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
      //  envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
    }

    public Horoscope Fetch()
    {
       HttpTransportSE httpRequest = new HttpTransportSE(URL);

        HoroscopeHandler horoscopeParser = new HoroscopeHandler();
        try
        {
             //Envoi de la requête
            httpRequest.call(SOAP_ACTION, envelope);
            //Obtention de la reponse
             SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
            //parsing de l'objet SOAP
            Xml.parse(response.toString(), horoscopeParser);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        return horoscopeParser.getHoroscopeJour();
    }

}

有人可以帮我:(这个错误是什么意思,我该如何解决?

4

0 回答 0