Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:34:20+00:00 2026-06-02T00:34:20+00:00

How can I map the response of SoapObject to MyObject using KvmSerializable? I read

  • 0

How can I map the response of SoapObject to MyObject using KvmSerializable?

I read wiki on ksoap2-android. But still cant do it.

I added a map to the envelope:

envelope.addMapping(NAMESPACE, "return", new GoodsObject().getClass());

But I get an exception:
java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
on the string

GoodsObject resultsRequestSOAP = (GoodsObject) envelope.bodyIn

The code is below.
I spent much time on this problem but still have no ideas (


Java class GoodsObject:

    package com.deaddy64.droid;

    import java.util.Hashtable;

    import org.ksoap2.serialization.KvmSerializable;
    import org.ksoap2.serialization.PropertyInfo;


    public class GoodsObject implements  KvmSerializable {

    /**
     * 
     */
    public String ref;
    public String DeletionMark;
    public String Code;
    public String Description;


    private static final long serialVersionUID = -4872313975732374054L;

    public void setref(String strref) {
        this.ref = strref;
        }

    public String getref() {
        return this.ref;
        }

    public void setDeletionMark(String strDeletionMark) {
        this.DeletionMark = strDeletionMark;
        }

    public String getDeletionMark() {
        return this.DeletionMark;
        }

    public void setCode(String strCode) {
        this.Code = strCode;
        }

    public String getCode() {
        return this.Code;
        }

    public void setDescription(String strDescription) {
        this.Description = strDescription;
        }

    public String getDescription() {
        return this.Description;
        }

    /* (non-Javadoc)
     * @see org.ksoap2.serialization.KvmSerializable#getProperty(int)
     */
    public Object getProperty(int index) {
        switch (index) {
           case 0:
               return ref;
           case 1:
               return DeletionMark;
           case 2:
               return Code;
           case 3:
               return Description;

    }
        return null;
    }

    /* (non-Javadoc)
     * @see org.ksoap2.serialization.KvmSerializable#getPropertyCount()
     */
    public int getPropertyCount() {
        // TODO Auto-generated method stub
        return 4;
    }



    /* (non-Javadoc)
     * @see org.ksoap2.serialization.KvmSerializable#setProperty(int, java.lang.Object)
     */
    public void setProperty(int index, Object value) {
        switch(index) {
        case 0:
            this.ref = value.toString();
            break;
        case 1:
            this.DeletionMark = value.toString();
            break;
        case 2:
            this.Code = value.toString();
            break;
        case 3:
            this.Description = value.toString();
            break;
        default:
            break;


     }

    }

    public void getPropertyInfo(int index, Hashtable properties,
            PropertyInfo info) {
        switch (index) {
           case 0:
               info.type = PropertyInfo.STRING_CLASS;
               info.name = "Ref";
               break;
           case 1:
               info.type = PropertyInfo.STRING_CLASS;
               info.name = "DeletionMark";
               break;
           case 2:
               info.type = PropertyInfo.STRING_CLASS;
               info.name = "Code";
               break;
           case 3:
               info.type = PropertyInfo.STRING_CLASS;
               info.name = "Description";
               break;

    }
        }
    }

This is ResponseDump:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body> <m:getReferenceResponse xmlns:m="com.deaddy64">
    <m:return xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Ref xmlns="http://v8.1c.ru/8.1/data/enterprise/current-config">7f4fb970-6a62-11e1-9bd0-001fd027b6bb</Ref>
        <DeletionMark xmlns="http://v8.1c.ru/8.1/data/enterprise/current-config">false</DeletionMark>
        <Code xmlns="http://v8.1c.ru/8.1/data/enterprise/current-config">000000003</Code>
        <Description xmlns="http://v8.1c.ru/8.1/data/enterprise/current-config">123</Description>
    </m:return>
</m:getReferenceResponse></soap:Body>
</soap:Envelope>

In debugger envelope.bodyIn is:

      (org.ksoap2.serialization.SoapObject) getReferenceResponse{return=anyType{Ref=7f4fb970-6a62-11e1-9bd0-001fd027b6bb; DeletionMark=false; Code=000000003; Description=123; }; }

Main activity:

    package com.deaddy64.droid;

    import java.io.IOException;

    import org.ksoap2.SoapEnvelope;
    import org.ksoap2.serialization.SoapObject;
    import org.ksoap2.serialization.SoapSerializationEnvelope;
    import org.ksoap2.transport.HttpTransportSE;
    import org.xmlpull.v1.XmlPullParserException;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.provider.ContactsContract.Contacts;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;


    public class Droid1Activity extends Activity {
        /** Called when the activity is first created. */

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);


            myButton.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {



                    String NAMESPACE = "com.deaddy64";
                    String URL = "http://10.0.2.2/InfoBase/ws/ws1.1cws";
                    String SOAP_ACTION = "com.deaddy64#testService:getReference";
                    String METHOD_NAME = "getReference";    


                    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

                    //envelope.dotNet = true;

                    envelope.setOutputSoapObject(request);
                    envelope.addMapping("http://v8.1c.ru/8.1/data/enterprise/current-config", "CatalogObject.Номенклатура", new GoodsObject().getClass());

                    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                    androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    androidHttpTransport.debug = true;
                    Log.v("dd64", "xml");
                    GoodsObject resultsRequestSOAP;
                    try {
                         // List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
                          //headerList.add(new HeaderProperty("Authorization", "Basic " + org.kobjects.base64.Base64.encode("username:password".getBytes())));
                        androidHttpTransport.call(SOAP_ACTION, envelope);
                        resultsRequestSOAP = (GoodsObject) envelope.getResponse();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (XmlPullParserException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    Log.v("dd64",androidHttpTransport.requestDump);
                    Log.v("dd64", androidHttpTransport.responseDump);




                }
            });
        }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:34:23+00:00Added an answer on June 2, 2026 at 12:34 am

    Try this:

    envelope.addMapping(NAMESPACE, "GoodsObject", new GoodsObject().getClass());
    

    and

    GoodsObject resultsRequestSOAP = (GoodsObject) envelope.getResponse();
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I map the value of an object collection using fluent mapping? I
I don't know what's make wrong, my map can load, but the image on
I applied a harris corner detection using openCV which gave me a response map
How I can map a service running on a specific port number to an
Is it expected behavior that two encodings can map to the same decoding? I'm
Can Automapper map values from a NameValueCollection onto an object, where target.Foo receives the
Short version: How can I map two columns from table A and B if
I have a table with two primary keys,how can i map the same in
In Bash I can create a map (hashtable) with this common construction hput() {
can i use fragments and map view in the same activity. I have seen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.