Android 如何使用web服务上载图像
我必须使用KSOP web服务上传图像。 我必须把它上传到服务器数据库。 我的其余数据都在Android 如何使用web服务上载图像,android,Android,我必须使用KSOP web服务上传图像。 我必须把它上传到服务器数据库。 我的其余数据都在 String strquery = "insert into SNGTADMIN.sprint_mobile_task_dtl(SITE_NBR,SITE_ASSET_NAME,TASK_ID, PHYSICAL_CONDITION,VISIBLE_RUST,BLACK_SMOKE,ENCLOSURE_OIL_LEAK,BATTERY_FLUID_LEAK,AUTO_EXERCISE_STATUS,BAT
String strquery = "insert into SNGTADMIN.sprint_mobile_task_dtl(SITE_NBR,SITE_ASSET_NAME,TASK_ID, PHYSICAL_CONDITION,VISIBLE_RUST,BLACK_SMOKE,ENCLOSURE_OIL_LEAK,BATTERY_FLUID_LEAK,AUTO_EXERCISE_STATUS,BATTERY_STATUS,TRANSFER_SWITCH_CONDITION,ALARM_NOT_RECV_BEFORE_REPAIR,ALARM_NOT_RECV_AFTER_REPAIR,ARRIVAL_FUEL_LEVEL,CUM_METER_READING,DESCRETE_ONSITE_WORK,FUTURE_RECOMMENDED_WORK,AFTERVISIT_EVAL_SUMMARY,ACCESS_INSTR_CLAR_NEEDED,MAINT_NOTES,FIELD_PROXIMITY) values('"+ siteId+ "','"+ asset_type+ "','1','" + phyCondion+ "','"+ visbleRust + "','" + heavyBlackSmoke+ "','"+ fuelOrOilLeak + "','" + bateryFluidLeaks+ "','"+ exceriseStatus
+ "','" + batteryStatus + "','" + transferSwitch+ "','" + beforeRepair + "','" + ostRepair
+ "','" + fuelLevelUponArrival + "','" + cumulativeRunHour+ "','"+ discretionaryWork + "','" + additionalWork+ "','"+ evaluationSummaryAfterVisit+ "','"+ accessInstrustions
+ "','" + maintenanceNotes+ "','"+ fieldFarmProximity + "')";
和使用
PropertyInfo pi = new PropertyInfo();
pi.setName("strSQl");
pi.setValue(strquery);
pi.setType(String.class);
request.addProperty(pi);
不知道如何在此查询中添加图像。它工作正常,如果我没有发送图像
帮助我。您必须将图像转换为
字节
,然后在base64
字符串中,将此base64字符串发送到服务器()或从图像创建字节[],并将其作为属性添加到您的请求(,)您可以这样做。。!!我通过调用.asmxwebservice
web服务的代码可以按如下方式编码:
public class FileUploader : System.Web.Services.WebService
{
[WebMethod]
public string UploadFile(byte[] f, string fileName)
{
// the byte array argument contains the content of the file
// the string argument contains the name and extension
// of the file passed in the byte array
try
{
// instance a memory stream and pass the
// byte array to its constructor
MemoryStream ms = new MemoryStream(f);
// instance a filestream pointing to the
// storage folder, use the original file name
// to name the resulting file
FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath
("~/TransientStorage/") +fileName, FileMode.Create);
// write the memory stream containing the original
// file as a byte array to the filestream
ms.WriteTo(fs);
// clean up
ms.Close();
fs.Close();
fs.Dispose();
// return OK if we made it this far
return "OK";
}
catch (Exception ex)
{
// return the error message if the operation fails
return ex.Message.ToString();
}
}
希望这对你有用。。如果你需要任何其他帮助。然后一定要问。一种方法是在base64中编码图像,然后在服务器上解码。Hi Nirmal我必须将该图像添加到表列中,以便……它应该在查询中。这就是问题所在。我对数据库一无所知。