问题描述
我desperatly搜索此XmlPullParserException在KSOAP2-的Android的原因。
这里是code:
字符串NAMESPACE =瓮:SAP-COM:文档:SAP:肥皂:功能:MC-式;
字符串METHOD_NAME =ZFanTestWs;
字符串SOAP_ACTION = NAMESPACE +/+ METHOD_NAME;
字符串的URL =?HTTP://xxxx.xxx.xx:8000 / SAP / BC / SRT / WSDL / bndg_xxx / wsdl11 / ALLINONE /标准/ RPC SAP客户端= XXX; SoapObject要求=新SoapObject空间(namespace,METHOD_NAME); PI的PropertyInfo =新的PropertyInfo();
pi.setName(arg0中);
pi.setValue(42);
pi.setType(PropertyInfo.INTEGER_CLASS);
request.addProperty(PI); SoapSerializationEnvelope信封=新SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(请求); HttpTransportSE androidHttpTransport =新HttpTransportSE(URL);
androidHttpTransport.debug = TRUE; 尝试
{
androidHttpTransport.call(SOAP_ACTION,信封);
SoapPrimitive resultsRequestSOAP =(SoapPrimitive)envelope.getResponse();
结果= resultsRequestSOAP.toString();
}
赶上(例外五)
{
e.printStackTrace();
}
上发生的异常androidHttpTransport.call(SOAP_ACTION,信封);
在HttpTransportSE的responeDump长相酷似我生成的WSDL:
&LT; WSDL:定义targetNamespace=\"urn:sap-com:document:sap:soap:functions:mc-style\"><wsdl:documentation><sidl:sidl/></wsdl:documentation><wsdl:types><xsd:schema attributeFormDefault =合格的targetNamespace =瓮:SAP-COM:文档:SAP:肥皂:功能:MC-风格&GT;&LT; XSD:元素名称=ZFanTestWs&GT;&LT; XSD:复杂类型&GT;&LT; XSD:序列&GT;&LT; XSD:元素名称=IvImportingTYPE =XSD:INT/&GT;&LT; / XSD:序列&GT;&LT; /为xsd:复杂类型&GT;&LT; / XSD:组件&gt;&LT; XSD:元素名称= ZFanTestWsResponse&GT;&LT; XSD:复杂类型&GT;&LT; XSD:序列&GT;&LT; XSD:元素名称=EvExporting type=\"xsd:int\"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message NAME =ZFanTestWs&GT;&LT; WSDL:部分名称=参数元素=TNS:ZFanTestWs/&GT;&LT; / WSDL:消息&GT;&LT; WSDL:消息名称=ZFanTestWsResponse&GT;&LT; WSDL:部件名称=参数元素=TNS:ZFanTestWsResponse/&GT;&LT; / WSDL:消息&GT;&LT; WSDL:portType的名称=Z_FAN_TEST_WS&GT;&LT; WSDL:操作名称=ZFanTestWs&GT;&LT; WSDL :输入消息=TNS:ZFanTestWs/&GT;&LT; WSDL:输出消息=TNS:ZFanTestWsResponse/&GT;&LT; / WSDL:操作&gt;&LT; / WSDL:portType的&GT;&LT; WSDL:绑定名称=DEFAULT TYPE =TNS:Z_FAN_TEST_WS&GT;&LT;肥皂:绑定传输=http://schemas.xmlsoap.org/soap/http的风格=文件/&GT;&LT; WSDL:操作名称=ZFanTestWs &GT;&LT;肥皂:操作的soapAction =的风格=文件/&GT;&LT; WSDL:输入&GT;&LT;肥皂:身体使用=文字/&GT;&LT; / WSDL:输入&GT;&LT; WSDL:输出&GT ;&LT;肥皂:身体使用=文字/&GT;&LT; / WSDL:输出&GT;&LT; / WSDL:操作&gt;&LT; / WSDL:结合&GT;&LT; WSDL:服务名称=Z_FAN_TEST_WS&GT;&LT; WSDL :端口名称=DEFAULT绑定=TNS:DEFAULT&GT;&LT;肥皂:地址location=\"http://xxxx.xxx.xx:8000/sap/bc/srt/rfc/sap/z_fan_test_ws/xxx/z_fan_test_ws/default\"/></wsdl:port></wsdl:service></wsdl:definitions>
这需要一个整数作为参数,并返回它。
是我的命名空间和SOAP_ACTION字符串是否正确?
请分享您的想法。谢谢你。
编辑:堆栈跟踪
10月1日至17日:12:11.090:W / System.err的(555):org.xmlpull.v1.XmlPullParserException:期望值START_TAG {HTTP://schemas.xmlsoap。组织/ SOAP /信封/}信封(位置:START_TAG&LT; {} http://schemas.xmlsoap.org/wsdl/ WSDL:定义的targetNamespace ='金塔:SAP-COM:文档:SAP:肥皂:功能:MC-风格'&GT; @ 1:429 java.io.InputStreamReader@41076710)
10月1日至17日:12:11.180:W / System.err的(555):在org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
10月1日至17日:12:11.190:W / System.err的(555):在org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
10月1日至17日:12:11.210:W / System.err的(555):在org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
10月1日至17日:12:11.221:W / System.err的(555):在org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
10月1日至17日:12:11.241:W / System.err的(555):在org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
10月1日至17日:12:11.260:W / System.err的(555):在webservice.test.WebServiceTestActivity $ ServiceCall.doInBackground(WebServiceTestActivity.java:111)
10月1日至17日:12:11.281:W / System.err的(555):在webservice.test.WebServiceTestActivity $ ServiceCall.doInBackground(WebServiceTestActivity.java:1)
10月1日至17日:12:11.292:W / System.err的(555):在android.os.AsyncTask $ 2.call(AsyncTask.java:264)
10月1日至17日:12:11.310:W / System.err的(555):在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)
10月1日至17日:12:11.331:W / System.err的(555):在java.util.concurrent.FutureTask.run(FutureTask.java:137)
10月1日至17日:12:11.340:W / System.err的(555):在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:208)
10月1日至17日:12:11.361:W / System.err的(555):在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10月1日至17日:12:11.371:W / System.err的(555):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:569)
10月1日至17日:12:11.390:W / System.err的(555):在java.lang.Thread.run(Thread.java:856)
我提供的WSDL文件KSOAP,这是完全错误的URL。
你必须提供给SOAP服务本身,这是在WSDL文件中列出的网址:
&LT;肥皂:地址位置=HTTP://xxxx.xxx.xx:8000 / SAP / BC / SRT / RFC / SAP / z_fan_test_ws / XXX / z_fan_test_ws /默认 /&GT;
字符串SOAP_ACTION = NAMESPACE +/+ METHOD_NAME;
在我的情况下正常工作。
感谢曼弗雷德Moser和JPriest为您解答!
I'm desperatly searching for the cause of this XmlPullParserException in KSOAP2-Android.Here is the code:
String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
String METHOD_NAME = "ZFanTestWs";
String SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;
String URL = "http://xxxx.xxx.xx:8000/sap/bc/srt/wsdl/bndg_xxx/wsdl11/allinone/standard/rpc?sap-client=xxx";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("arg0");
pi.setValue(42);
pi.setType(PropertyInfo.INTEGER_CLASS);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
result = resultsRequestSOAP.toString();
}
catch(Exception e)
{
e.printStackTrace();
}
The exception occurs on "androidHttpTransport.call(SOAP_ACTION, envelope);"
The responeDump of the HttpTransportSE looks exactly like my generated WSDL:
<wsdl:definitions targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"><wsdl:documentation><sidl:sidl/></wsdl:documentation><wsdl:types><xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"><xsd:element name="ZFanTestWs"><xsd:complexType><xsd:sequence><xsd:element name="IvImporting" type="xsd:int"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="ZFanTestWsResponse"><xsd:complexType><xsd:sequence><xsd:element name="EvExporting" type="xsd:int"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message name="ZFanTestWs"><wsdl:part name="parameters" element="tns:ZFanTestWs"/></wsdl:message><wsdl:message name="ZFanTestWsResponse"><wsdl:part name="parameter" element="tns:ZFanTestWsResponse"/></wsdl:message><wsdl:portType name="Z_FAN_TEST_WS"><wsdl:operation name="ZFanTestWs"><wsdl:input message="tns:ZFanTestWs"/><wsdl:output message="tns:ZFanTestWsResponse"/></wsdl:operation></wsdl:portType><wsdl:binding name="DEFAULT" type="tns:Z_FAN_TEST_WS"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><wsdl:operation name="ZFanTestWs"><soap:operation soapAction="" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="Z_FAN_TEST_WS"><wsdl:port name="DEFAULT" binding="tns:DEFAULT"><soap:address location="http://xxxx.xxx.xx:8000/sap/bc/srt/rfc/sap/z_fan_test_ws/xxx/z_fan_test_ws/default"/></wsdl:port></wsdl:service></wsdl:definitions>
It takes an integer as a parameter and returns it.Are my NAMESPACE and SOAP_ACTION strings correct?Please share your ideas. Thanks.
edit: stack trace
01-17 10:12:11.090: W/System.err(555): 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:429 in java.io.InputStreamReader@41076710)
01-17 10:12:11.180: W/System.err(555): at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
01-17 10:12:11.190: W/System.err(555): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
01-17 10:12:11.210: W/System.err(555): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
01-17 10:12:11.221: W/System.err(555): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
01-17 10:12:11.241: W/System.err(555): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
01-17 10:12:11.260: W/System.err(555): at webservice.test.WebServiceTestActivity$ServiceCall.doInBackground(WebServiceTestActivity.java:111)
01-17 10:12:11.281: W/System.err(555): at webservice.test.WebServiceTestActivity$ServiceCall.doInBackground(WebServiceTestActivity.java:1)
01-17 10:12:11.292: W/System.err(555): at android.os.AsyncTask$2.call(AsyncTask.java:264)
01-17 10:12:11.310: W/System.err(555): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-17 10:12:11.331: W/System.err(555): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-17 10:12:11.340: W/System.err(555): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
01-17 10:12:11.361: W/System.err(555): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
01-17 10:12:11.371: W/System.err(555): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
01-17 10:12:11.390: W/System.err(555): at java.lang.Thread.run(Thread.java:856)
I've provided the URL of the WSDL file to KSOAP, which is completely wrong.You have to supply to URL of the SOAP service itself, which is listed in the WSDL file:
<soap:address location="http://xxxx.xxx.xx:8000/sap/bc/srt/rfc/sap/z_fan_test_ws/xxx/z_fan_test_ws/default"/>
String SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;works fine in my case.
Thanks Manfred Moser and JPriest for your answers!
这篇关于使用SAP WSDL webservice时XmlPullParserException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!