关于org.xmlpull.v1.XmlPullParserException: expected:....的问题求解答!

长方体混凝土移动大师 发布于 2017/06/19 16:21
阅读 3K+
收藏 0

错误日志:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style'>@1:686 in java.io.InputStreamReader@fcd6521) 
	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:129)
	at org.ksoap2.transport.HttpTransportSE.parseResponse(HttpTransportSE.java:304)
	at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:276)
	at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118)
	at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113)
	at com.cxg.blueboothpinter.com.utils.WebServiceUtils.callWebService1(WebServiceUtils.java:63)
	at com.cxg.blueboothpinter.ExampleUnitTest.init1(ExampleUnitTest.java:29)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)

代码:

//命名空间
    public static String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
    //请求方法名
    public static String METHOD_NAME = "ZwmRfcIts003";
    //请求路径
    public static String SOAP_ACTION = "urn:sap-com:document:sap:soap:functions:mc-style/ZwmRfcIts003";
    //请求的webservice路径
    public static final String URL = "http://IP:8000/sap/bc/srt/wsdl/srvc_58F9EDF150950D90E1008000C0A80010/wsdl11/allinone/ws_policy/document?sap-client=700&sap-user=******&sap-password=*******";
    /**
     * call WebService1
     *
     * @param url        WebService服务器地址
     * @param methodName WebService的调用方法名
     * @param properties WebService的参数
     */
    public static void callWebService1(String url, final String methodName, HashMap<String, String> properties) {
        SoapObject request = new SoapObject(NAMESPACE, methodName);// set up
        // SoapObject添加参数
        if (properties != null) {
            for (Iterator<Map.Entry<String, String>> it = properties.entrySet().iterator(); it.hasNext(); ) {
                Map.Entry<String, String> entry = it.next();
                request.addProperty(entry.getKey(), entry.getValue());
            }
        }

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); // put all required data into a soap
        envelope.dotNet = false;
        envelope.setOutputSoapObject(request);

        HttpTransportSE httpTransport = new HttpTransportSE(url);
        httpTransport.debug = true;
        try {
            httpTransport.call(SOAP_ACTION, envelope);
            SoapObject result = (SoapObject) envelope.bodyIn;
            for (int i = 0; i < result.getPropertyCount(); i++) {
                SoapObject obj3 = (SoapObject) result.getProperty(0);
                System.out.println("result is " + obj3);
            }
        } catch (SocketException ex) {
            ex.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

上述代码中的IP值对应我的真实IP。

出错代码的位置:

httpTransport.call(SOAP_ACTION, envelope);

WSDL 文件:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
<wsdl:documentation>
<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/>
</wsdl:documentation>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:Policy wsu:Id="BN_BN_binding">
<saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/>
<saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
<wsp:ExactlyOne xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"/>
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
</wsp:Policy>
<wsp:Policy wsu:Id="BN_BN_binding_SOAP12">
<saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/>
<saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
<wsp:ExactlyOne xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"/>
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
</wsp:Policy>
<wsp:Policy wsu:Id="IF_IF_ZWMITS3">
<sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/">
<sapsession:enableSession>false</sapsession:enableSession>
</sapsession:Session>
<sapcentraladmin:CentralAdministration xmlns:sapcentraladmin="http://www.sap.com/webas/700/soap/features/CentralAdministration/" wsp:Optional="true">
<sapcentraladmin:BusinessApplicationID>55C3FFE181C11070E1008000C0A8000D</sapcentraladmin:BusinessApplicationID>
</sapcentraladmin:CentralAdministration>
</wsp:Policy>
<wsp:Policy wsu:Id="OP_IF_OP_ZwmRfcIts003">
<sapcomhnd:enableCommit xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/">false</sapcomhnd:enableCommit>
<sapblock:enableBlocking xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/">true</sapblock:enableBlocking>
<saptrhnw05:required xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/">no</saptrhnw05:required>
<saprmnw05:enableWSRM xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/">false</saprmnw05:enableWSRM>
</wsp:Policy>
<wsdl:types>
<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
<xsd:simpleType name="char1">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char10">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char12">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="12"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char18">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="18"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char2">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char20">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char220">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="220"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char35">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="35"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char4">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="4"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char40">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="40"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char5">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="clnt3">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="3"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="date">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
<xsd:pattern value="\d\d\d\d-\d\d-\d\d"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="numeric10">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
<xsd:pattern value="\d*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="numeric4">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="4"/>
<xsd:pattern value="\d*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="quantum13.3">
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="13"/>
<xsd:fractionDigits value="3"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="unit3">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="3"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
<xsd:schema xmlns:n0="urn:sap-com:document:sap:rfc:functions" attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
<xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>
<xsd:complexType name="Ztwm004">
<xsd:sequence>
<xsd:element name="Mandt" type="n0:clnt3"/>
<xsd:element name="Zipcode" type="n0:char20"/>
<xsd:element name="Charg" type="n0:char10"/>
<xsd:element name="Zcupno" type="n0:char12"/>
<xsd:element name="Werks" type="n0:char4"/>
<xsd:element name="Zkurno" type="n0:char10"/>
<xsd:element name="Zbc" type="n0:char1"/>
<xsd:element name="Zlinecode" type="n0:char2"/>
<xsd:element name="Matnr" type="n0:char18"/>
<xsd:element name="Zproddate" type="n0:date"/>
<xsd:element name="Zinstock" type="n0:char1"/>
<xsd:element name="Zoutstock" type="n0:char1"/>
<xsd:element name="Mblnr" type="n0:char10"/>
<xsd:element name="Mjahr" type="n0:numeric4"/>
<xsd:element name="Menge" type="n0:quantum13.3"/>
<xsd:element name="Meins" type="n0:unit3"/>
<xsd:element name="Tanum" type="n0:numeric10"/>
<xsd:element name="Zptflg" type="n0:char1"/>
<xsd:element name="Zgrdate" type="n0:date"/>
<xsd:element name="Zlichn" type="n0:char5"/>
<xsd:element name="Lifnr" type="n0:char10"/>
<xsd:element name="Znum" type="n0:char10"/>
<xsd:element name="Zqcnum" type="n0:char10"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ZwmRfcIts003">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="IZipcode" type="n0:char20" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ZwmRfcIts003Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EMaktx" type="n0:char40"/>
<xsd:element name="EMessage" type="n0:char220"/>
<xsd:element name="EName1" type="n0:char35"/>
<xsd:element name="EName2" type="n0:char35"/>
<xsd:element name="EType" type="n0:char1"/>
<xsd:element name="EsZtwm004" type="tns:Ztwm004"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ZwmRfcIts003">
<wsdl:part name="parameters" element="tns:ZwmRfcIts003"/>
</wsdl:message>
<wsdl:message name="ZwmRfcIts003Response">
<wsdl:part name="parameter" element="tns:ZwmRfcIts003Response"/>
</wsdl:message>
<wsdl:portType name="ZWMITS3">
<wsdl:documentation>
<sapdoc:sapdoc xmlns:sapdoc="urn:sap:esi:documentation">
<sapdoc:docitem docURL="http://sapqas:8000/sap/bc/esdt/docu/sd_text?sap-client=700&sd_name=ZWMITS3"/>
</sapdoc:sapdoc>
</wsdl:documentation>
<wsp:Policy>
<wsp:PolicyReference URI="#IF_IF_ZWMITS3"/>
</wsp:Policy>
<wsdl:operation name="ZwmRfcIts003">
<wsp:Policy>
<wsp:PolicyReference URI="#OP_IF_OP_ZwmRfcIts003"/>
</wsp:Policy>
<wsdl:input message="tns:ZwmRfcIts003"/>
<wsdl:output message="tns:ZwmRfcIts003Response"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="binding" type="tns:ZWMITS3">
<wsp:Policy>
<wsp:PolicyReference URI="#BN_BN_binding"/>
</wsp:Policy>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ZwmRfcIts003">
<soap:operation style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="binding_SOAP12" type="tns:ZWMITS3">
<wsp:Policy>
<wsp:PolicyReference URI="#BN_BN_binding_SOAP12"/>
</wsp:Policy>
<wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ZwmRfcIts003">
<wsoap12:operation style="document"/>
<wsdl:input>
<wsoap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsoap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ZWMITS3">
<wsdl:port name="binding" binding="tns:binding">
<soap:address location="http://sapqas:8000/sap/bc/srt/rfc/sap/zwmits3/700/zwmits3/binding"/>
</wsdl:port>
<wsdl:port name="binding_SOAP12" binding="tns:binding_SOAP12">
<wsoap12:address location="http://sapqas:8000/sap/bc/srt/rfc/sap/zwmits3/700/zwmits3/binding"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

在单元测试的时候,在执行到上述一行的代码中时就会出现错误,并无法执行,经过各种尝试之后,还是没有解决,希望路过的各位大神指点~

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部