androidarraysblobksoap

How to get blob data as byte array type in android with ksoap?


I have a web service and I reach it with ksoap library in my android application. My code is given below;

Data.java

public class Data implements KvmSerializable{

public byte[] byteValue;

public Data(){

}

public Data(byte[] byteValue) {
    this.byteValue = byteValue;
}

@Override
public Object getProperty(int arg0) {
    switch(arg0) {
        case 0:
            return byteValue;
    }
    return null;
}

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

@Override
public void setProperty(int index, Object o) {
    switch (index) {  
        case 0:
            byteValue = (byte[]) o;
            break;        
    }
}

@Override
public void getPropertyInfo(int i, Hashtable arg1, PropertyInfo info) {

    switch(i) {
        case 0:
            info.type = MarshalBase64.BYTE_ARRAY_CLASS;
            info.name = "byteValue";
            break;        
    }

}

There is a blob value in my database different from the image. When I use following code,

SoapObject response = (SoapObject) envelope.getResponse();
response.getProperty(0);

I get object type value, but for my android application I need to get this value as byte[] type. How can I do this?


Solution

  • I found the right solution for my application.

    In my activity class, i tried below code :

    byte[] byteValue = Base64.decode(response.getProperty(0).toString().getBytes(), Base64.DEFAULT);