0

我正在制作一个调用 Zend(php 框架)中制作的 wsdl webservice 的示例,并且我正在使用 ksoap api(jar 文件)并且出现此错误

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <definitions name='Ccc_Core_Model_Api_Server' targetNamespace='http://gsmadmin.com/zendtest/api'>@2:385 in java.io.InputStreamReader@40539078)

我阅读了与此错误相关的所有 stackoverflow 问题,但我无法解决此错误。

这个错误的真正解决方案是什么?

请帮我。

我的 wsdl xml 文件是:

<?xml version="1.0"?>              
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://gsmadmin.com/zendtest/api" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Ccc_Core_Model_Api_Server" targetNamespace="http://gsmadmin.com/zendtest/api"> 
<types>             
<xsd:schema targetNamespace="http://gsmadmin.com/zendtest/api"/>  
</types>    
<portType name="Ccc_Core_Model_Api_ServerPort">  
<operation name="addition">  
<documentation> This method is used for addition of two numbers</documentation>
<input message="tns:additionIn"/>
<output message="tns:additionOut"/>
</operation> 
<operation name="substraction">   
<documentation> This method is used for substraction of two numbers</documentation> 
<input message="tns:substractionIn"/>
<output message="tns:substractionOut"/>  
</operation>    
<operation name="multiple">  
<documentation>This method is used for multiple of two numbers</documentation>   
<input message="tns:multipleIn"/> 
<output message="tns:multipleOut"/>  
</operation> 
<operation name="division">   
<documentation>This method is used for division of two numbers</documentation>
<input message="tns:divisionIn"/> 
<output message="tns:divisionOut"/> 
</operation>   
</portType>  
<binding name="Ccc_Core_Model_Api_ServerBinding" type="tns:Ccc_Core_Model_Api_ServerPort">  
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="addition">  
<soap:operation soapAction="http://gsmadmin.com/zendtest/api#addition"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/> 
</input> 
<output> 
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/>  
</output>  
</operation>   
<operation name="substraction">  
<soap:operation soapAction="http://gsmadmin.com/zendtest/api#substraction"/> 
<input>   
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/>
</input>  
<output>   
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/>  
</output>
</operation>  
<operation name="multiple"> 
<soap:operation soapAction="http://gsmadmin.com/zendtest/api#multiple"/>  
<input>    
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/>
</input>   
<output>  
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/>
</output>
</operation>   
<operation name="division">
<soap:operation soapAction="http://gsmadmin.com/zendtest/api#division"/>    
<input>  
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/>   
</input>
<output>   
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://gsmadmin.com/zendtest/api"/> 
</output>  
</operation>  
</binding>  
<service name="Ccc_Core_Model_Api_ServerService">  
<port name="Ccc_Core_Model_Api_ServerPort" binding="tns:Ccc_Core_Model_Api_ServerBinding">  
<soap:address location="http://gsmadmin.com/zendtest/api"/>  
</port>  
</service>   
<message name="additionIn">   
<part name="param1" type="xsd:int"/>   
<part name="param2" type="xsd:int"/>  
</message> 
<message name="additionOut">  
<part name="return" type="xsd:float"/>  
</message>   
<message name="substractionIn"> 
<part name="param1" type="xsd:int"/> 
<part name="param2" type="xsd:int"/>
</message>    
<message name="substractionOut">   
<part name="return" type="xsd:float"/>     
</message>     
<message name="multipleIn">     
<part name="param1" type="xsd:int"/>      
<part name="param2" type="xsd:int"/>
</message> 
<message name="multipleOut">   
<part name="return" type="xsd:float"/>    
</message>   
<message name="divisionIn">    
<part name="param1" type="xsd:float"/>  
<part name="param2" type="xsd:float"/> 
</message>    
<message name="divisionOut"> 
<part name="return" type="xsd:float"/>  
</message>
</definitions>  

异常堆栈跟踪:

06-14 15:45:49.527: D/AndroidRuntime(2055): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-14 15:45:49.527: D/AndroidRuntime(2055): CheckJNI is ON
06-14 15:45:50.587: D/AndroidRuntime(2055): Calling main entry com.android.commands.pm.Pm
06-14 15:45:50.637: D/AndroidRuntime(2055): Shutting down VM
06-14 15:45:50.657: D/dalvikvm(2055): GC_CONCURRENT freed 101K, 71% free 297K/1024K, external 0K/0K, paused 1ms+1ms
06-14 15:45:50.657: I/AndroidRuntime(2055): NOTE: attach of thread 'Binder Thread #3' failed
06-14 15:45:50.669: D/jdwp(2055): Got wake-up signal, bailing out of select
06-14 15:45:50.677: D/dalvikvm(2055): Debugger has detached; object registry had 1 entries
06-14 15:45:51.247: D/AndroidRuntime(2065): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-14 15:45:51.247: D/AndroidRuntime(2065): CheckJNI is ON
06-14 15:45:52.147: D/AndroidRuntime(2065): Calling main entry com.android.commands.am.Am
06-14 15:45:52.197: I/ActivityManager(61): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.phpwebservice/.PhpwebservicedemoActivity } from pid 2065
06-14 15:45:52.267: D/AndroidRuntime(2065): Shutting down VM
06-14 15:45:52.317: D/dalvikvm(2065): GC_CONCURRENT freed 103K, 69% free 319K/1024K, external 0K/0K, paused 2ms+1ms
06-14 15:45:52.389: V/Adapter(1868): URL = http://gsmadmin.com/zendtest/api?wsdl
06-14 15:45:52.389: D/jdwp(2065): Got wake-up signal, bailing out of select
06-14 15:45:52.389: D/dalvikvm(2065): Debugger has detached; object registry had 1 entries
06-14 15:45:52.447: V/Adapter(1868): NAMESPACE = http://gsmadmin.com/zendtest/api
06-14 15:45:52.447: V/Adapter(1868): METHOD_NAME = addition
06-14 15:45:52.447: V/Adapter(1868): SOAP_ACTION = http://gsmadmin.com/zendtest/api#addition
06-14 15:45:52.447: V/Adapter(1868): request = addition{param1=10; param2=2; }
06-14 15:45:52.487: V/Adapter(1868): param1 = 10  param2 = 2
06-14 15:45:53.737: W/System.err(1868): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <definitions name='Ccc_Core_Model_Api_Server' targetNamespace='http://gsmadmin.com/zendtest/api'>@2:385 in java.io.InputStreamReader@40541998) 
06-14 15:45:53.757: W/System.err(1868):     at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
06-14 15:45:53.757: W/System.err(1868):     at org.kxml2.io.KXmlParser.require(KXmlParser.java:1424)
06-14 15:45:53.757: W/System.err(1868):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
06-14 15:45:53.766: W/System.err(1868):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
06-14 15:45:53.766: W/System.err(1868):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
06-14 15:45:53.766: W/System.err(1868):     at com.phpwebservice.Adapter.addition(Adapter.java:59)
06-14 15:45:53.777: W/System.err(1868):     at com.phpwebservice.PhpwebservicedemoActivity.onCreate(PhpwebservicedemoActivity.java:53)
06-14 15:45:53.777: W/System.err(1868):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-14 15:45:53.787: W/System.err(1868):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-14 15:45:53.787: W/System.err(1868):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-14 15:45:53.787: W/System.err(1868):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-14 15:45:53.787: W/System.err(1868):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-14 15:45:53.809: W/System.err(1868):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-14 15:45:53.809: W/System.err(1868):     at android.os.Looper.loop(Looper.java:123)
06-14 15:45:53.809: W/System.err(1868):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-14 15:45:53.809: W/System.err(1868):     at java.lang.reflect.Method.invokeNative(Native Method)
06-14 15:45:53.817: W/System.err(1868):     at java.lang.reflect.Method.invoke(Method.java:507)
06-14 15:45:53.817: W/System.err(1868):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-14 15:45:53.817: W/System.err(1868):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-14 15:45:53.817: W/System.err(1868):     at dalvik.system.NativeStart.main(Native Method)
06-14 15:45:53.817: V/log_tag(1868): total addition = 0.0
06-14 15:45:54.069: I/ActivityManager(61): Displayed com.phpwebservice/.PhpwebservicedemoActivity: +1s835ms
06-14 15:45:59.297: D/dalvikvm(126): GC_EXPLICIT freed 4K, 50% free 3003K/5895K, external 5903K/7371K, paused 63ms

提前致谢

4

2 回答 2

0

xml 中有一个错误,从您发布的内容来看,我认为没有开始标签。如果您发布更多堆栈跟踪,则可能更容易看出问题所在。

于 2012-06-13T07:43:42.957 回答
0

呜……

终于经过3天的尝试,我得到了解决方案,

问题出在 URL 中,

URL 是“http://gsmadmin.com/zendtest/api?wsdl”

现在我将其更改为“http://gsmadmin.com/zendtest/api”

但我不知道为什么需要从 url 中删除 ?wsdl,因为在以前的项目中,我最后使用了带有 ?wsdl 的 URL(它是在 java - JAX-WS-RI 中制作的),但最近如果我使用带有?wsdl 然后它给了我错误,

两种 web 服务都是用不同的技术制作的,一种是用 JAVA 制作的,另一种是用 zend(php 框架)制作的,所以可能结构不同,

但终于放松了……

谢谢.......

于 2012-06-15T09:19:29.407 回答