I have Android / Java project with Network threads. It is connected to WCF WebService which provides me method GetAddonsTypes.
GetAddonsTypes return long, int, and string items so I use own Parser (String / regex) which also create object in myDataSource (it's SQLite database). Now I have problem with my second method which is called GetProducts. GetProducts return long, int and Image.
I Would like to store Image as byte[] type. But how I can deal with binary files with SoapObjects? Maybe I should cast this anyType{} to binary file, but how I can do it?
This is how looks SoapObject result from GetProducts (.toString())
anyType{DocumentElement=anyType{Tabela=anyType{ID=701; lg=1; ProductImage=anyType{}; };
Thread networkThread1 = new Thread() {
@Override
public void run() {
try {
final String METHOD_NAME = "GetAddonsTypes";
final String SOAP_ACTION = "http://tempuri.org/IService1/GetAddonsTypes";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE ht = new HttpTransportSE(URL);
ht.call(SOAP_ACTION, envelope);
final SoapObject result=(SoapObject)envelope.getResponse();
runOnUiThread (new Runnable(){
public void run() {
ParseTable(result.getProperty(1).toString());
}
});
}
catch (Exception e) {
Log.e("WS", e.toString());
}
}
};
public void ParseTable(String input)
{
myDataSource myDatasource;
Pattern p = Pattern.compile("(PID=)(\\d*); (flg=)(\\d*); (Name=)(\\w*);");
Matcher m = p.matcher(input);
myDatasource = new myDatasource(this);
myDatasource.open();
while (m.find()) {
try {
myDatasource.createMyItem(Long.parseLong(m.group(2)), Integer.parseInt(m.group(4)), m.group(6));
}
catch (Exception e) {
Log.e("Parser Error", e.toString());
}
}
myDatasource.close();
}
Maybe this will help:
" In the getProperty method I'm using the following:
Info.type = MarshalBase64.BYTE_ARRAY_CLASS "
From this post: http://supportforums.blackberry.com/t5/Java-Development/Getting-Image-Over-Using-Web-Service-and-Ksoap2/td-p/491835