1
我從ASP DynamicPopulateExtender調用Web服務,但似乎得到「Web服務調用失敗:0」錯誤,就好像它沒有找到Web服務。是否有錯誤代碼0適用的另一個原因?從DynamicPopulateExtender調用時出現「Web服務調用失敗:0」
這裏的.aspx文件:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<h1>Stock Updates</h1>
<asp:Panel ID="upExtenderContent" runat="server" CssClass="dynamicPopulate_Normal">
Stock file import has STARTED please wait....<br /><br />
<asp:Image ID="imgLoading" runat="server" ImageUrl="~/admin/adminimages/uploading.gif" />
</asp:Panel>
<asp:DynamicPopulateExtender ID="dpeAjaxImport" runat="server"
TargetControlID="upExtenderContent"
BehaviorID="dp1"
ClearContentsDuringUpdate="false"
ServiceMethod="importStock"
ServicePath="importFile.asmx"
ContextKey="none"
PopulateTriggerControlID="btnImport">
</asp:DynamicPopulateExtender>
<br />
<asp:Button ID="btnImport" runat="server" OnClick="importFile" Text="Upload" />
<script type="text/javascript">
function uploadData(value) {
var behavior = $find('dp1');
if (behavior) {
behavior.populate(value);
}
}
Sys.Application.add_load(function() { uploadData('c:/Ben_Saved_Small.csv'); });
</script>
的importFile.asmx文件,服務所在是在相同的目錄上面.aspx文件等都應該很容易被發現:
<%@ WebService Language="C#" CodeBehind="importFile.asmx.cs" Class="GG.co.uk.admin.importFile" %>
該文件頭文件涉及以下文件內容:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using System.Text;
using System.IO;
using GG.co.uk.App_Code;
using GGDAL;
namespace GG.co.uk.admin
{
/// <summary>
/// Summary description for importFile
/// </summary>
[WebService(Namespace = "http://GG.co.uk.admin/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class importFile : System.Web.Services.WebService
{
[WebMethod]
public static string importStock(string contextKey)
{
string returnResponse="";
//Load data into website database
try
{
//Read and process files
}
catch (Exception ex)
{
returnResponse = returnResponse + "<span style=\"color:red;font-weight:bold;\">Uh-Oh! " + ex.Message + "</span> : " + contextKey;
}
return returnResponse + "<br />";
}
}
}
一個光棚上這個w應該真的有幫助。
謝謝。
得到它
ContextKey = 「無」! 顯然,即使看起來完成,服務仍然從最後一次調用運行,因此後續調用返回「失敗:0」。 –