How to pass a value to the enum flag parameter in a Soap service (ASMX service) From an Android application

I want to call a soap web service in an Android app that needs an enum value as a parameter, which is an enumeration of a flag. How do I pass a value as a flag enumeration for this web service method from an Android application?

I use Ksoap to call a soap service.

This web service method:

[WebMethod]
    public ReceptionCommitResult CommitReceiption(some parameters, EnumName myEnum)
    {
        //mehod body
    }

and web service enumeration:

[Flags]
public enum EnumName 
{
    One= 0,
    Two = 1,
    Three = 2,
    Four = 4,
    Five = 8,

}

finally I got the code to call the service:

SoapObject soapObj = new SoapObject(ServiceUtil.WSDL_TARGET_NAMESPACE, "RCI");

AttributeInfo attrInfo = new AttributeInfo();
attrInfo.setName("myEnum");
attrInfo.setValue("");
attrInfo.setType(EnumName.class);
soapObj.addAttribute(attrInfo);

 SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
_envelope.skipNullProperties = false;

_envelope.implicitTypes = true;
_envelope.dotNet = true;
_envelope.setOutputSoapObject(_client);
_envelope.bodyOut = _client;

_envelope.addMapping(WSDL_TARGET_NAMESPACE, "RCI",new MyClassObject().getClass());

HttpTransportSE httpTransport1 = new HttpTransportSE(ServiceUtil.SOAP_ADDRESS, 60000000);
httpTransport1.debug = true;
 httpTransport1.call(ServiceUtil.SOAP_ACTION, _envelope);
+4
source share
2 answers

# enum 32/64 . enum webservice.

, - :

AttributeInfo attrInfo = new AttributeInfo();
attrInfo.setName("myEnum");
attrInfo.setValue("5");  //For a value of Two | Four
attrInfo.setType(EnumName.class);
soapObj.addAttribute(attrInfo);
0

:

public enum EnumName {
    One(1),Two(2),Three(3);

    public final int value;

    MyEnum(final int value) {
        this.value = value;
    }
}

, :

EnumName e = EnumName.One;
int value = e.value; //= 1
String name = e.name(); // = "One"

on:

EnumName e = EnumName.One;
AttributeInfo attrInfo = new AttributeInfo();
attrInfo.setName(e.name());
attrInfo.setValue(e.value);  //For a value of Two | Four
attrInfo.setType(EnumName.class);
soapObj.addAttribute(attrInfo);

, , , :

wcf webservice

0

All Articles