2015-04-03 57 views
0

我正尝试从Web服务调用Web方法“注册”。它包含一个输入参数和一个输出。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(); 
     } 

但OM 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> 

我对类似的问题解析计算器,但它不帮我。

回答

1

我尝试这样做,是正确的对我说:

嗯,我想NAMESPACE字符串应该是SoapObject构造函数的第一个参数。同为()方法调用(这里应该是NAMESPACE + METHOD_NAME作为第一个参数)

而且试试这个:

_envelope.setOutputSoapObject(_client); 

,而不是这样的:

_envelope.bodyOut = _client; 

获得响应:这取决于您的Web服务正在返回什么(原始或复杂的对象?)

答案来自this link

相关问题