我在我的 android 应用程序中使用 ksoap2 api 作为参考,将数据从我的 android 应用程序存储到远程 SQL Server 数据库。这个想法是保存用户数据,这些数据是为构建用户配置文件而收集的信息。我在下面使用了这个内部doInBackground()
方法 :AsyncTask
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("userName",username.getText().toString());
request.addProperty("eamil",email.getText().toString());
request.addProperty("gender",gender.getSelectedItem().toString());
request.addProperty("country",country.getSelectedItem().toString());
request.addProperty("about",about.getText().toString() );
request.addProperty("pic",byteArray);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,20000);
androidHttpTransport.call(SOAP_ACTION1, envelope);
if (envelope.bodyIn instanceof SoapFault) {
String str= ((SoapFault) envelope.bodyIn).faultstring;
Log.i("fault", str);
} else {
SoapObject result = (SoapObject)envelope.bodyIn;
if(result != null)
{
message=result.getProperty(0).toString();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return message;
问题是,当我添加时 request.addProperty("pic",byteArray);
收到一个错误,指出无法序列化 Ksoap2,但是当我将类型byteArray
从类型byte[ ]
更改为string
正确执行的请求并将数据保存在我的数据库中时。这是我的网络服务的截图
Public Function AddUser(userName As String, email As String, gender As String, country As String, about As String, pic As Byte()) as String
// Some code to add data to databae
Return "you are done"
End Function
任何有关此问题的帮助将不胜感激
问候