错误:未定义Web服务

时间:2014-02-04 06:30:38

标签: web-services asmx

我已经创建了webservice,我正在尝试使用javascript来使用它,但是当我调用webservice方法时,它会给出错误Webservice没有定义。我已经参考了它。

<asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
       <asp:ServiceReference Path="../WebService.asmx" />
    </Services>
       </asp:ScriptManager>

我的方法

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 WebService : System.Web.Services.WebService
{
    CultureInfo cul = new CultureInfo("gu-IN", true);
    protected sdData s = new sdData();
    protected component comp = new component();
    public ClsVB objvb = new ClsVB();
    DBAccess dbAccess = new DBAccess();

    public WebService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string SubmitDDIPo(string txtCaseNoDDIPO, int txtDDIPO, int txtAmount, string txtDDDate, string txtBank, string District_Code )
    {

javascript方法调用

<script type="text/javascript">
            function addDDIPO() {
                "DDIPOdiv".Obctrl().style.display = "block";
                "fadeDiv".Obctrl().style.display = "block";

            }
            function submitDDIPO()
             {
                 WebService.SubmitDDIPo("txtCaseNoDDIPO".Obctrl().value, "txtDDIPO".Obctrl().value, "txtAmount".Obctrl().value, "txtDDDate".Obctrl().value, "txtBank".Obctrl().value, Session["District_Code"].ToString(), ResultSubmitSucess, ResultFailure);
             }
            </script>

这是我缺少的东西吗? 请帮忙

1 个答案:

答案 0 :(得分:2)

尝试取消注释[System.Web.Script.Services.ScriptService]

如果uncommneted属性不起作用,请检查命名空间。 ScriptManager创建完整路径的javascript客户端代理。 Ej:namespace1.namespace2.WSClassName.Method()。您还可以尝试将客户端代理内联以查看js源,以便使用ServiceReference.InlineScript属性轻松找到它。