2015-04-03 2 views
0

Я пытаюсь вызвать веб-метод «Регистрация» из веб-службы. Он содержит один входной параметр и один выход.SOAP org.xmlpull.v1.XmlPullParserException: ожидается: START_TAG

HttpTransportSE httpTransport=null; 

     try 
     { 
      String organization = "Слоник Зеленый"; 

      String method = "Registration"; 
      SoapObject request = new SoapObject("http://www.ServiceDesk.org", method); 

      PropertyInfo pi1 = new PropertyInfo(); 
      pi1.setName("Organisation"); 
      pi1.setValue(organization); 
      pi1.setType(String.class); 
      request.addProperty(pi1); 



      SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //VER.10,VER.11,VER.12 don't help 
      envelope.setOutputSoapObject(request); 
//   envelope.implicitTypes = true; #don't help me 

      envelope.dotNet = false; # "true" value don't help 
      List<HeaderProperty> headerList = new ArrayList<HeaderProperty>(); 
      headerList.add(new HeaderProperty("Authorization", "Basic " + org.kobjects.base64.Base64.encode("user:password".getBytes()))); 


      httpTransport = new HttpTransportSE(MainAsync.wsdlSchema); 

      httpTransport.debug=true; 
      httpTransport.call("http://www.ServiceDesk.org#ServiceDesk:Registration", envelope,headerList); 

      SoapObject result =(SoapObject) envelope.bodyIn; 
      String roleId = result.getProperty("return").toString(); 

      httpTransport.reset(); 

      return roleId; 
     } catch (Exception e) { 
      Log.e(httpTransport.responseDump); 
      Log.e("Request "+httpTransport.requestDump); 

      e.printStackTrace(); 
      if(httpTransport!=null) 
       httpTransport.reset(); 
      return""; 
     } finally{ 
      if(httpTransport!=null) 
       httpTransport.reset(); 
     } 

Но ом nethod вызов, я хочу получить следующую ошибку:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <definitions name='ServiceDesk' targetNamespace='http://www.ServiceDesk.org'>@9:48 in [email protected]) 
    at org.kxml2.io.KXmlParser.exception(KXmlParser.java:242) 
    at org.kxml2.io.KXmlParser.require(KXmlParser.java:1384) 
    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:128) 
    at org.ksoap2.transport.Transport.parseResponse(Transport.java:118) 
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:275) 
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118) 

Это мой файл WSDL:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12bind="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ServiceDesk.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://www.ServiceDesk.org" name="ServiceDesk" targetNamespace="http://www.ServiceDesk.org"> 
<types> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs1="http://www.ServiceDesk.org" targetNamespace="http://www.ServiceDesk.org" elementFormDefault="qualified"> 
<xs:element name="Registration"> 
<xs:complexType> 
<xs:sequence> 
<xs:element name="Organisation" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</types> 
<message name="RegistrationRequestMessage"> 
<part name="parameters" element="tns:Registration"/> 
</message> 
<message name="RegistrationResponseMessage"> 
<part name="parameters" element="tns:RegistrationResponse"/> 
</message> 
<portType name="ServiceDeskPortType"> 
<operation name="Registration"> 
<input message="tns:RegistrationRequestMessage"/> 
<output message="tns:RegistrationResponseMessage"/> 
</operation> 
<binding name="ServiceDeskSoapBinding" type="tns:ServiceDeskPortType"> 
<soapbind:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
<operation name="Registration"> 
<soapbind:operation style="document" soapAction="http://www.ServiceDesk.org#ServiceDesk:Registration"/> 
<input> 
<soapbind:body use="literal"/> 
</input> 
<output> 
<soapbind:body use="literal"/> 
</output> 
</operation> 
</binding-name> 
<service name="ServiceDesk"> 
<port name="ServiceDeskSoap" binding="tns:ServiceDeskSoapBinding"> 
<documentation> 
<wsi:Claim xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/" conformsTo="http://ws-i.org/profiles/basic/1.1"/> 
</documentation> 
<soapbind:address location="http://volga.rarus.ru/abc2009_artur/ru/ws/ServiceDesk"/> 
</port> 
<port name="ServiceDeskSoap12" binding="tns:ServiceDeskSoap12Binding"> 
<soap12bind:address location="http://volga.rarus.ru/abc2009_artur/ru/ws/ServiceDesk"/> 
</port> 
</service> 

Я синтаксический анализ StackOverflow на подобные вопросы, но не помоги мне.

ответ

1

я попытался это и было правильным для меня:

Ну, я думаю, что NAMESPACE строка должна быть первым аргументом в SoapObject конструктора. То же самое для метода вызова() (здесь должна быть NAMESPACE + METHOD_NAME в качестве первого параметра)

И попробуйте это:

_envelope.setOutputSoapObject(_client); 

вместо этого:

_envelope.bodyOut = _client; 

Чтобы получить ответ : это зависит от того, что возвращается ваш веб-сервис (примитивный или сложный объект?)

От this link:

Смежные вопросы