android中的ksoap2在多数组数据检索中

发布于 2024-11-06 12:05:32 字数 3037 浏览 1 评论 0原文

实际上我有一项用于搜索员工的服务。该服务以多个数组形式提供结果,例如:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平安喜乐 2024-11-13 12:05:32

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文