android - How to pass an enum value to wcf webservice -


can ksoap2 pass enum webservice?

there wcf webservice:

[operationcontract] string testenum(codetype code); 

codetype dotnet enum:

    public enum codetype     {         [enummember]         all,          [enummember]         vehiclecolor     } 

how can call wcf webservice @ android client?

i create enum codetype , implements kvmserializable. in method getpropertyinfo, value of info.name(info.type)?

public enum codetype implements kvmserializable, baseinterface {     all,      vehiclecolor; //.......     @override     public void getpropertyinfo(int index, hashtable properties, propertyinfo info) {         //info.namespace = this.namespace;         info.name = ?;         info.type = ?;      } } 

thanks help.

i solved enum-problem via marshal.

i created java-enum "copying" .net one. wrote marshal-class it:

public class marshalenum implements org.ksoap2.serialization.marshal {     ... // singleton-pattern       public object readinstance(xmlpullparser xpp, string string, string string1,                            propertyinfo pi)         throws ioexception, xmlpullparserexception {     return myenum.valueof( xpp.nexttext() ); }  public void writeinstance(xmlserializer xs, object o)         throws ioexception {     xs.text(((myenum)o).name()); }  public void register(soapserializationenvelope sse) {     sse.addmapping(sse.xsd, "myenum", myenum.class, marshalenum.getinstance() ); } } // class 

then, when calling method myenum-values shall sent:

//... blah blah soapserializationenvelope envelope =                           new soapserializationenvelope(soapenvelope.ver11); envelope.addmapping(soap_remote_namespace, "myenum", myenum.class,                            marshalenum.getinstance()); //... , on. 

note soap_remote_namespace data contract namespace of enum used! see wsdl-file find out if you're not sure. should "http://schemas.datacontract.org/2009/08/your.dotnet.namespace".

i hope going work you, too.


Comments