Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Service receives null when client tries to send complex type object
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
İlker Argın  
View profile  
 More options Feb 21, 11:00 am
From: İlker Argın <argin.il...@gmail.com>
Date: Tue, 21 Feb 2012 08:00:24 -0800 (PST)
Local: Tues, Feb 21 2012 11:00 am
Subject: Service receives null when client tries to send complex type object
I try to write an Android application that connects to a .NET WCF web
service. When I tried to send primitive types, the server received
those values and sent a correct response. However, when I try to send
a complex type object, it cannot receive that object, it receives null
and sends a response accordingly. Here is the class definition of the
object that i want to send to the service.

import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;

public class TwoIntegerWrapper implements KvmSerializable {

        private int Num1;
        private int Num2;

        public TwoIntegerWrapper() {
                super();
        }

        TwoIntegerWrapper(int number1, int number2) {
                super();
                this.Num1 = number1;
                this.Num2 = number2;
        }

        public int getNumber1() {
                return Num1;
        }

        public void setNumber1(int number1) {
                this.Num1 = number1;
        }

        public int getNumber2() {
                return Num2;
        }

        public void setNumber2(int number2) {
                this.Num2 = number2;
        }

        public Object getProperty(int propertyNumber) {

                Object property = null;

                switch (propertyNumber) {
                case 0:
                        property = this.Num1;
                        break;

                case 1:
                        property = this.Num2;
                        break;

                }

                return property;
        }

        public int getPropertyCount() {
                return 2;
        }

        public void getPropertyInfo(int propertyNumber, Hashtable arg1,
                        PropertyInfo propertyInfo) {

                switch (propertyNumber) {
                case 0:
                        propertyInfo.type = PropertyInfo.INTEGER_CLASS;
                        propertyInfo.name = "Num1";
                        break;
                case 1:
                        propertyInfo.type = PropertyInfo.INTEGER_CLASS;
                        propertyInfo.name = "Num2";
                        break;
                }

        }

        public void setProperty(int propertyNumber, Object data) {
                switch (propertyNumber) {

                case 0:
                        this.Num1 = Integer.parseInt(data.toString());
                        break;
                case 1:
                        this.Num2 = Integer.parseInt(data.toString());
                        break;
                }

        }

}

And here is how I call the web service.

                        SoapObject request = new SoapObject(NAMESPACE,
METHOD_NAME2);

                        PropertyInfo property = new PropertyInfo();

                        TwoIntegerWrapper tiw = new TwoIntegerWrapper(num1Value,
num2Value);

                        property.setName("TwoIntegerWrapper");
                        property.setType(tiw.getClass());
                        property.setValue(tiw);
                        request.addProperty(property);

                        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                                        SoapEnvelope.VER11);
                        envelope.dotNet = true;
                        envelope.setOutputSoapObject(request);

                        envelope.addMapping(NAMESPACE, tiw.getClass().getSimpleName(),
TwoIntegerWrapper.class);

                        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                        androidHttpTransport.debug = true;

                        try {
                                androidHttpTransport.call(Add_SOAP_ACTION, envelope);

                                Log.d(logtag + " request dump", androidHttpTransport.requestDump);
                                Log.d(logtag + " response dump",
androidHttpTransport.responseDump);

                                SoapPrimitive sp = (SoapPrimitive) envelope.getResponse();
                                result = Integer.parseInt(sp.toString());

                        } catch (Exception e) {
                                Log.e(logtag, e.getMessage());

                        }

And request dump is the following:

<v:Envelope xmlns:i="w3.org/2001/XMLSchema-instance" xmlns:d="w3.org/
2001/XMLSchema" xmlns:c="schemas.xmlsoap.org/soap/encoding/"
xmlns:v="schemas.xmlsoap.org/soap/envelope/">
        <v:Header />
        <v:Body>
                <AddNumbers2 xmlns="tempuri.org/" id="o0" c:root="1">
                        <TwoIntegerWrapper i:type="n0:TwoIntegerWrapper"
xmlns:n0="tempuri.org/">
                                <Num1 i:type="d:int">1</Num1>
                                <Num2 i:type="d:int">3</Num2>
                        </TwoIntegerWrapper>
                </AddNumbers2>
        </v:Body>
</v:Envelope>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »