WCF - Android - Problem sending Complex Type

60 views
Skip to first unread message

chankly

unread,
Jan 13, 2012, 11:18:15 AM1/13/12
to ksoap2-android
Hi guys !!!

First... i'm sorry for my english... i am spanish, sorry.

I have a strange problem with my comunications.

I send a complex type from android to my service and i have anything
problem. All OK.

My service wcf recived the object, but... the properties is empty !!

however, my service update the properties and return to the client
which recived correctly the object with the values properties OK.


Please... can you help me??


My client code is this:

*************************
METHOD ACTIVITY WHICH CALL WEBSERVICE
*************************
private class LaunchWebService extends AsyncTask<String, String,
Integer>
{

@Override
protected Integer doInBackground(String... params)
{


try
{

SoapObject request = new SoapObject(NAMESPACE,
METHOD_NAME);

//*** OBJECT ***
CompositeType objComposite = new
CompositeType();
objComposite.setProperty(0, true); //This
arrive false.
objComposite.setProperty(1, "this arrive
null");

//*** ADD NEW PROPERTY TO ENVELOPE WITH THE
OBJECT ***
PropertyInfo objParameter = new PropertyInfo();
objParameter.setName("http://
schemas.xmlsoap.org/soap/
envelope/");
objParameter.setName("composite");
objParameter.setValue(objComposite);
objParameter.setType(CompositeType.class);

request.addProperty(objParameter);


SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE_CONTRACT,
"CompositeType",
CompositeType.class);


HttpTransportSE androidHttpTransport = new
HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION,
envelope);

SoapObject response =
(SoapObject)envelope.getResponse();
String txt =
response.getProperty("StringValue").toString();

publishProgress(txt);

return 1;
}
catch(SoapFault exSoap)
{

exSoap.printStackTrace();

publishProgress(exSoap.getMessage());

return -1;
}
catch(Exception ex)
{

ex.printStackTrace();

publishProgress(ex.getMessage());

return -1;
}
}






*************************
COMPLEX TYPE DEFINITION
*************************
public class CompositeType implements KvmSerializable{

public static final int STRING_VALUE = 1;
public static final int BOOLEAN_VALUE = 0;

public String StringValue;
public Boolean BoolValue;

public CompositeType() {
}

@Override
public String toString() {
return "StringValue = " + StringValue + ", BoolValue = " +
BoolValue.toString();
}

@Override
public Object getProperty(int arg0) {
switch(arg0)
{
case STRING_VALUE:
return StringValue;
case BOOLEAN_VALUE:
return BoolValue;
}

return null;
}

@Override
public int getPropertyCount() {
return 2;
}

@Override
public void getPropertyInfo(int index, @SuppressWarnings("rawtypes")
Hashtable arg1, PropertyInfo info) {
switch(index)
{
case STRING_VALUE:
info.type = PropertyInfo.STRING_CLASS;
info.name = "StringValue";
break;
case BOOLEAN_VALUE:
info.type = PropertyInfo.BOOLEAN_CLASS;
info.name = "BoolValue";
break;
default:break;
}
}

@Override
public void setProperty(int index, Object value) {
switch(index)
{
case STRING_VALUE:
StringValue = value.toString();
break;
case BOOLEAN_VALUE:
BoolValue = Boolean.parseBoolean(value.toString());
break;
default:
break;
}
}


}
Reply all
Reply to author
Forward
0 new messages