Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using web service in aspx

Status
Not open for further replies.

harmmeijer

Programmer
Mar 1, 2001
869
CN
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=&quot;utf-8&quot; %>
<%@ Import Namespace=&quot;System.Web.UI.Page&quot; %>
<%@ Import Namespace=&quot;System.Threading&quot; %>
<%@ Import Namespace=&quot;System.Data&quot; %>
<%@ Import Namespace=&quot;System.Data.Sql&quot; %>
<script language=&quot;VB&quot; runat=&quot;server&quot;>
dim math as new localhost.MathService
but it doesn't work

<%@ WebService Language=&quot;VB&quot; Class=&quot;MathService&quot; %>

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
 
By the way the error I am getting is:
Type 'localhost.MathService' is not defined
 
hi harmmeijer,

are you using visual studio.net? if so, you should have added the web references first. you could simply do this :
click Project -> Add Web References...
then in the textbox give, you fill the address of your web service.
for example :
then you can simply use your web service in your aspx file, if you would like to see 'bout the namespace, use the class view :
click View -> Class View

hope this could help you ^-^
 
No sorry, I have still visual studio on my machine and I need to use it.
So on both NT and 2000 machines I do not have the guts to install .net because I am quite sure it will not work properly with visual studio 6.
 
ooohhh... i get it... well, why don't u install it? well, on my machine visual studio 6 and visual studio.net are running very well ^-^ no problem at all

well, i've read an article about using web service manually (without visual studio help at all)... but i've forgotten what've written on it :)... well, i'll try to find it
 
oh yes, you've to use the wsdl command to make a dll from the web service in your local system, then you should put that on your bin folder of your web app ^-^

hope this information is useful :)
 
Okidoki, I installed .net on another test computer wich had vb6.
Seems to work ok exept for the errormessages I get from my old asp pages.
If there is any error I just get 500 internal server error.
 
haha ^-^

it's worth a try, isn't it :), nothing to lose anyway :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top