【问题标题】:SOAP org.xmlpull.v1.XmlPullParserException: expected: START_TAGSOAP org.xmlpull.v1.XmlPullParserException:预期:START_TAG
【发布时间】:2015-04-03 07:55:47
【问题描述】:

我正在尝试从网络服务调用网络方法“注册”。它包含一个输入参数和一个输出。

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 java.io.InputStreamReader@76ed5528) 
    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,但这对我没有帮助。

【问题讨论】:

    标签: java xml web-services soap wsdl


    【解决方案1】:

    我试过了,对我来说是正确的:

    好吧,我认为 NAMESPACE 字符串应该是 SoapObject 构造函数中的第一个参数。 call()方法也一样(这里应该是NAMESPACE + METHOD_NAME 作为第一个参数)

    试试这个:

    _envelope.setOutputSoapObject(_client);
    

    而不是这个:

    _envelope.bodyOut = _client;
    

    要获得响应:这取决于您的 Web 服务返回的内容(原始对象还是复杂对象?)

    this link的回答:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-18
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      相关资源
      最近更新 更多