2012-01-16 44 views
1

我正在絕望地搜索KSOAP2-Android中此XmlPullParserException的原因。 下面是代碼:當使用SAP WSDL WebService時XmlPullParserException

  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(); 
      } 

上發生異常 「androidHttpTransport.call(SOAP_ACTION,信封);」

的HttpTransportSE的responeDump長相酷似我的生成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> 

它需要一個整數作爲參數,並返回。 我的NAMESPACE和SOAP_ACTION字符串是否正確? 請分享你的想法。謝謝。

編輯:堆棧跟蹤

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 [email protected]) 
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) 
+0

異常的堆棧跟蹤會告訴你.. – 2012-01-17 06:39:56

+0

不幸的是,堆棧跟蹤不是很有幫助 - 我已經將它添加到上面。 它以某種方式在正確接收的WSDL中看不到開始標記。 – user1152221 2012-01-17 09:19:03

+0

你將不得不調試它,看看發生了什麼。它可能是無序的或什麼都混在一起。有一件事讓我覺得你做錯了,就是響應看起來像一個wsdl ..並且它不應該.. – 2012-01-17 16:50:41

回答

1

我提供的WSDL文件KSOAP,這是完全錯誤的URL。 你必須提供給SOAP服務本身,這是在WSDL文件中列出的網址:

<soap:address location="http://xxxx.xxx.xx:8000/sap/bc/srt/rfc/sap/z_fan_test_ws/xxx/z_fan_test_ws/default"/> 

字符串SOAP_ACTION = NAMESPACE + 「/」 + METHOD_NAME; 在我的情況下工作正常。

感謝Manfred Moser和JPriest爲您解答!

0

你的SOAPAction應該爲空字符串,如下:

String SOAP_ACTION = "";