VS setup for creating ASP web services

N

Niall Smith

I am trying to create a ASP.net web service. I have used the New Project> ASP.Net web service generator. And I have added the lines of code:
<WebMethod()> Public Function HelloWorld() As String
HelloWorld = "Hello World"
End Function

<WebMethod()> Public Function getRating(ByVal Input As String) As String
If Input = 1 Then
Return "x"
Else
Return "y"
End If
End Function

When I build and browse, view in browser or type the URL http://localhost/WebService1/Service1.asmx in a browser I get "No page to display" in the browser and the following code in service1.asmx
<%@ WebService Language="vb" Codebehind="Service1.asmx.vb" Class="WebService1.Service1" %>

I beleive I should get a displayed web page with an input and ability to click "getRating"

Also if I type http://localhost/WebService1/Service1.asmx?wsdl I don't get a generated WSDL file the same thing happens as described above. I don't think there is anything wrong with the code as I copied it straight from a training exercise.

What could be wrong with my VStudio installation
 
N

Niall Smith

Here is all of the code in service1.asmx.vb


Imports System.Web.Services

<WebService(Namespace := "http://tempuri.org/")> _
Public Class Service1
Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "

Public Sub New()
MyBase.New()

'This call is required by the Web Services Designer.
InitializeComponent()

'Add your own initialization code after the InitializeComponent() call

End Sub

'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

#End Region

' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the project.
' To test this web service, ensure that the .asmx file is the start page
' and press F5.
'
<WebMethod()> Public Function HelloWorld() As String
HelloWorld = "Hello World"
End Function

<WebMethod()> Public Function getRating(ByVal Input As String) As String
If Input = 1 Then
Return "x"
Else
Return "y"
End If
End Function

End Class
 
S

Saurabh Nandu

Hi,

May be your ASP.NET runtime has not been registered correctly.

Run the following command in the
c:\windows\microsoft.net\framework\<version>\ directory

aspnet_regiis -i

This will install the ASP.net runtime with IIS.

Regards,
Akila
[MVP|MCAD]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top