我正在尝试将图像文件从Android和ios设备上传到asmx网络服务,但我收到的错误列表如下:
for Android: 服务器上的FileNotFoundException FileTransfer.upload出错 FileTransfer.execute出错 IOException:从服务器收到错误。 “http_status”:500,“code”:1
适用于iOS: 服务器上的FileNotFoundException FileTransfer.upload出错 FileTransfer.execute出错 IOException:从服务器收到错误。 “http_status”:500,“code”: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
我的cordova版本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
亲切的问候。
答案 0 :(得分:0)
httpstaus 500是服务器错误。 您的UploadFile函数似乎存在错误。
您可以将w3wp.exe附加到进程以测试您的服务