0

我必须使用 KSOP 网络服务上传图像。我必须将其上传到服务器数据库。我的其余数据在

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);

不知道如何在此查询中添加图像。如果我没有发送图像,它可以正常工作。

帮我。

4

2 回答 2

0

你可以这样做..!! 我已经通过调用.asmx webservice

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();    
    }    
}

希望这对你有用..如果你需要任何其他帮助。然后问。

于 2013-06-27T11:12:36.087 回答
0

您必须将图像转换为字符串,bytes然后base64将此 base64 字符串发送到服务器(1)或从图像创建 byte[] 并将其作为属性添加到您的请求2、3

于 2013-06-27T10:41:31.153 回答