harmmeijer
Programmer
I have the following sample code (see below)
saved this as test.asmx in the directory
how can I use this service in a file called test.aspx located in the direcory?
I tried something like this:
<%@ Page ResponseEncoding="utf-8" %>
<%@ Import Namespace="System.Web.UI.Page" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql" %>
<script language="VB" runat="server">
dim math as new localhost.MathService
but it doesn't work
<%@ WebService Language="VB" Class="MathService" %>
Imports System
Imports System.Web.Services
Public Class MathService : Inherits WebService
<WebMethod()> Public Function Add(A As System.Single, B As System.Single) As System.Single
Return A + B
End Function
<WebMethod()> Public Function Subtract(A As System.Single, B As System.Single) As System.Single
Return A - B
End Function
<WebMethod()> Public Function Multiply(A As System.Single, B As System.Single) As System.Single
Return A * B
End Function
<WebMethod()> Public Function Divide(A As System.Single, B As System.Single) As System.Single
If B = 0
Return -1
End If
Return Convert.ToSingle(A / B)
End Function
End Class
saved this as test.asmx in the directory
how can I use this service in a file called test.aspx located in the direcory?
I tried something like this:
<%@ Page ResponseEncoding="utf-8" %>
<%@ Import Namespace="System.Web.UI.Page" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql" %>
<script language="VB" runat="server">
dim math as new localhost.MathService
but it doesn't work
<%@ WebService Language="VB" Class="MathService" %>
Imports System
Imports System.Web.Services
Public Class MathService : Inherits WebService
<WebMethod()> Public Function Add(A As System.Single, B As System.Single) As System.Single
Return A + B
End Function
<WebMethod()> Public Function Subtract(A As System.Single, B As System.Single) As System.Single
Return A - B
End Function
<WebMethod()> Public Function Multiply(A As System.Single, B As System.Single) As System.Single
Return A * B
End Function
<WebMethod()> Public Function Divide(A As System.Single, B As System.Single) As System.Single
If B = 0
Return -1
End If
Return Convert.ToSingle(A / B)
End Function
End Class