2

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

2
  • Try using SoapObject result=(SoapObject) envelope.getResponse(); SoapObject mainResult = (SoapObject) result.getProperty(0); .Then tell me whats the result. Commented May 12, 2011 at 10:28
  • Shashank since it gives me exception on the line SoapObject result=(SoapObject) envelope.getResponse(); so there is no way its going on the second line. Commented May 12, 2011 at 11:11

1 Answer 1

7

envelope.getResponse() can return a SoapObject, or a SoapPrimitive/Vector, I think you're casting a Vector on a SoapObject

Sign up to request clarification or add additional context in comments.

2 Comments

can please tell me how to parse the xml?
Here's some useful links: Parsing a complex type: seesharpgears.blogspot.com/2010/10/… and parsing a vector (end of the page): code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.