开发者

"Web service call failed: 0" when calling from DynamicPopulateExtender

I am calling a web service from an ASP DynamicPopulateExtender, but seem to get the "Web Service Call Failed: 0" error, as if it's not finding the web service. Is there another reason why error code 0 would apply?

Here's the .aspx file:

    <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="upExtenderCo开发者_JAVA百科ntent" 
            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>

The importFile.asmx file, where the service resides is in the same directory as the above .aspx file so should be found easily:

<%@ WebService Language="C#" CodeBehind="importFile.asmx.cs" Class="GG.co.uk.admin.importFile" %>

This file header reference the following file content:

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 />";
    }
}
}

An light shed on this would be really helpful.

Thanks.


Remove

ContextKey="none"

in

DynamicPopulateExtender tag

and try

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜