我在我的android應用程序中使用ksoap2 api作爲參考,將數據從我的android應用程序存儲到遠程SQL服務器數據庫。這個想法是保存作爲收集信息的用戶數據來構建用戶配置文件。我在AsyncTask
如下使用該內部doInBackground()
方法:使用ksoap2將Byte []保存到遠程數據庫中?
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
請求正確執行並保存在我的數據庫中的數據。下面是從我的web
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
關於這個問題的任何幫助snipshote將完全理解
問候