从DynamicPopulateExtender调用时出现“Web服务调用失败:0”

问题描述:

我从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应该真的有帮助。
谢谢。

+0

得到它

ContextKey = “无”! 显然,即使看起来完成,服务仍然从最后一次调用运行,因此后续调用返回“失败:0”。 –

删除

DynamicPopulateExtender标签

,并尝试