2016-05-09 2 views
0

мне нужно позвонить в службу и получить приведенные данные в функции обратного вызова от него, но я получаю JS ошибки:обслуживания вызовов в клиентской стороне

Uncaught ReferenceError: InvoiceHTMLService is not defined.

Пожалуйста, помогите - ниже мои страницы и класс

Мои Aspx страница

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="InvoiceHTML.aspx.vb" Inherits="WebApplication2.InvoiceHTML" %> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server"> 
    <title>Web Service call from client-side JavaScript</title> 

    <script type="text/javascript"> 
     function SendRequest() { 
      debugger; 
      InvoiceHTMLService.GetBillInvoiceHtmlData(); 
     } 
     function OnComplete(arg) { 
      alert(arg); 
     } 
     function OnTimeOut(arg) { 
      alert("timeOut has occured"); 
     } 
     function OnError(arg) { 
      alert("error has occured: " + arg._message); 
     } 


    </script> 
    </head> 
    <body> 
    <form id="form1" runat="server"> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    <Services> 
    <asp:ServiceReference Path="~/Service/InvoiceHTMLService.asmx" /> 
    </Services> 
    </asp:ScriptManager> 
    <div> 
    <input type="text" value="" id="MyTextBox" /> 
    <input type="button" value="Send Request to the Web Service" 
      id="RequestButton" onclick="return SendRequest()" /> 
    </div> 
    </form> 
    </body> 
    </html> 

мой ASMX страница

Imports System.Web.Script.Services 
Imports System.Web.Services 
Imports System.Collections.Generic 
Imports System.Text 
Imports System.Drawing 

Imports System.Web.Services.Protocols 
Imports System.ComponentModel 

Imports System.IO 
Imports ClassLibrary1 


' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
' <System.Web.Script.Services.ScriptService()> _ 
<WebService()> _ 
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
<ScriptService()> _ 
Public Class InvoiceHTMLService 
    Inherits System.Web.Services.WebService 


    <WebMethod()> _ 
    Public Function GetBillInvoiceHtmlData() As Object 
     Dim objDAOBill As DAOInvoice 
     Dim Obj As Object 

     objDAOBill = New DAOInvoice() 

     Obj = objDAOBill.GetBillInvoiceHtmlData() 
     Return Obj 
    End Function 

End Class 

ответ

0

Я получил ответ за это спасибо всем, я отправляю ответ, чтобы он мог помочь другим, вызов службы с клиентской стороны можно сделать, используя полное имя класса, присутствующего на странице .asmx. В моем случае

<%@ WebService Language="vb" CodeBehind="InvoiceHTMLService.asmx.vb" Class="App.InvoiceHTMLService" %> 

Так что я должен вызвать службу в следующим образом:

function SendRequest() { 

       App.InvoiceHTMLService.GetBillInvoiceHtmlData(callback); 
      }