android中的ksoap2在多数组数据检索中
实际上我有一项用于搜索员工的服务。该服务以多个数组形式提供结果,例如:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:searchResponse xmlns:ns1="urn:abcdwsdl">
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[6]">
<item xsi:type="xsd:string">success</item>
<item xsi:type="xsd:string">Search results retrieved for *</item>
<item xsi:type="xsd:">
<item>
<ad_id xsi:type="xsd:string">2</ad_id>
<fname xsi:type="xsd:string">abcr</ad_text>
<lname xsi:type="xsd:string">def</location>
<phone xsi:type="xsd:float">123456</lati>
<address xsi:type="xsd:float">America</longi>
</item>
<item>
<ad_id xsi:type="xsd:string">12</ad_id>
<fnamet xsi:type="xsd:string">test user</ad_text>
<lname xsi:type="xsd:string">hello</location>
<phone xsi:type="xsd:float">987654543</lati>
<address xsi:type="xsd:float">England</longi>
</item>
</item>
<item xsi:type="xsd:int">2</item>
<item xsi:type="xsd:int">0</item>
<item xsi:type="xsd:int">0</item>
</return>
</ns1:searchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
现在我添加了以下代码:
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result=(SoapObject) envelope.getResponse();
但是 getResponse 给了我以下错误:
in catch
java.lang.ClassCastException: java.util.Vector
at org.test.search.FirstActivity.loginMethod(FirstActivity.java:74)
at org.test.search.FirstActivity.onCreate(FirstActivity.java:26)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
请朋友帮忙。我已经在帖子中提出了我的问题
从 android 中的 ksoap2 获取数据
actually I have a service for search an employee.. that service gives me result in multiple array form like:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:searchResponse xmlns:ns1="urn:abcdwsdl">
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[6]">
<item xsi:type="xsd:string">success</item>
<item xsi:type="xsd:string">Search results retrieved for *</item>
<item xsi:type="xsd:">
<item>
<ad_id xsi:type="xsd:string">2</ad_id>
<fname xsi:type="xsd:string">abcr</ad_text>
<lname xsi:type="xsd:string">def</location>
<phone xsi:type="xsd:float">123456</lati>
<address xsi:type="xsd:float">America</longi>
</item>
<item>
<ad_id xsi:type="xsd:string">12</ad_id>
<fnamet xsi:type="xsd:string">test user</ad_text>
<lname xsi:type="xsd:string">hello</location>
<phone xsi:type="xsd:float">987654543</lati>
<address xsi:type="xsd:float">England</longi>
</item>
</item>
<item xsi:type="xsd:int">2</item>
<item xsi:type="xsd:int">0</item>
<item xsi:type="xsd:int">0</item>
</return>
</ns1:searchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Now i added the following code:
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result=(SoapObject) envelope.getResponse();
But getResponse Gives me the following Error:
in catch
java.lang.ClassCastException: java.util.Vector
at org.test.search.FirstActivity.loginMethod(FirstActivity.java:74)
at org.test.search.FirstActivity.onCreate(FirstActivity.java:26)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Please friends Help in this. i already have asked my question on the post
get data from ksoap2 in android
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Envelope.getResponse() 可以返回 SoapObject 或 SoapPrimitive/Vector,我认为您正在将 Vector 投射到 SoapObject 上
envelope.getResponse() can return a SoapObject, or a SoapPrimitive/Vector, I think you're casting a Vector on a SoapObject