0

我正在尝试从 Android 和 ios 设备将图像文件上传到 asmx Web 服务,但出现以下错误:

对于 Android:服务器上的 FileNotFoundException FileTransfer.upload 上的错误 FileTransfer.execute 上的错误 IOException:收到来自服务器的错误。“http_status”:500,“代码”:1

对于 iOS:服务器上的 FileNotFoundException FileTransfer.upload 上的错误 FileTransfer.execute 上的错误 IOException:收到来自服务器的错误。“http_status”:500,“代码”:3

我正在使用 Icenium 进行开发,并且 ft.upload() 方法的 service_url 参数正在工作,我可以在浏览器上调用 Web 服务,但是当我尝试在我的项目中使用时,我遇到了同样的错误。

IIS 日志如下:

软件:Microsoft Internet Information Services 7.5

版本:1.0

日期:2013-02-22 11:00:07

字段:日期时间 s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken

2013-02-22 11:00:07 192.168.1.103 POST /ExpenseService.asmx/UploadFile - 40201 - 78.189.173.183 Camera%20Sample%20Official/1.0+CFNetwork/609+Darwin/13.0.0 500 0 0 287 2013-02-22 11:01:28 192.168.1.103 POST /ExpenseService.asmx/UploadFile - 40201 - 78.189.173.183 Camera%20Sample%20Official/1.0+CFNetwork/609+Darwin/13.0.0 500 0 0 144

我的科尔多瓦 2.2.0 版。任何想法我做错了什么?

ASMX 服务:

#region FileUpload
    [WebMethod]
    //[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public string UploadFile()
    {
        try
        {
            File.WriteAllText(@"d:\test.txt", "hede");
            HttpPostedFile file = HttpContext.Current.Request.Files[0];
            if (file == null)
                return null;
            string targetFilePath = @"d:\" + file.FileName;
            file.SaveAs(targetFilePath);
            return file.FileName.ToString();
        }
        catch (Exception ex)
        {
            File.WriteAllText(@"d:\uploader.txt", ex.Message.ToString());
            return null;
        }

    }
    #endregion

客户端:

var options = new FileUploadOptions(); 
options.chunkedMode  = false;
options.fileKey = "ficheFile";
console.log('imageFileName: ' + imageFileName);    
options.fileName = imageFileName; 
options.mimeType="image/jpeg";
console.log('imageSrc: ' + imageSrc);

var ft = new FileTransfer(); 
ft.upload(imageSrc, encodeURI("http://mydomain:40201/ExpenseService.asmx/UploadFile"), win, fail, options); 

这是我的 adb logcat:

E/FileTransfer(11472): {"target":"http:\/\/mydomain:40201\/ExpenseService.asmx\/SaveFile","source":"file:\/\/\/mnt
\/sdcard\/Android\/data\/com.telerik.Camera_Sample_Official\/cache\/1361950930301.jpg","http_status":500,"code":1}
E/FileTransfer(11472): java.io.FileNotFoundException: http://78.189.173.183:40201/ExpenseService.asmx/SaveFile
E/FileTransfer(11472):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(H
ttpURLConnectionImpl.java:521)
E/FileTransfer(11472):  at org.apache.cordova.FileTransfer.getInputStream(FileTransfer.java:480)
E/FileTransfer(11472):  at org.apache.cordova.FileTransfer.access$400(FileTransfer.java:62)
E/FileTransfer(11472):  at org.apache.cordova.FileTransfer$1.run(FileTransfer.java:402)
E/FileTransfer(11472):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
E/FileTransfer(11472):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
E/FileTransfer(11472):  at java.lang.Thread.run(Thread.java:1019)
D/CordovaLog(11472): Error Code: 1
D/CordovaLog(11472): : Line 1153648589 : Error Code: 1
I/Web Console(11472): Error Code: 1 at :1153648589

亲切的问候。

4

1 回答 1

0

httpstaus 500 是服务器错误。您的 UploadFile 函数中似乎存在错误。

您可以将 w3wp.exe 附加到进程以测试您的服务

于 2013-02-22T14:35:50.903 回答