«Ошибка вызова веб-службы: 0» при вызове из DynamicPopulateExtender - PullRequest
1 голос
/ 22 сентября 2011

Я вызываю веб-службу из ASP DynamicPopulateExtender, но, похоже, получаю ошибку «Ошибка вызова веб-службы: 0», как будто она не находит веб-службу. Есть ли другая причина, по которой будет применяться код ошибки 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 />";
    }
}
}

Пролить свет на это было бы очень полезно.
Спасибо.

1 Ответ

0 голосов
/ 23 апреля 2014

Удалить

нет

ContextKey = "ни"

в

тег DynamicPopulateExtender

и попробуйте

...