Simple WebService

  • Thread starter Thread starter author
  • Start date Start date
A

author

Newbie Q...

When I hit the "ws.asmx" in a browser, I get
"Parser Error Message: Could not create type 'Service1'" ??

If I use the file "ws_ok.asmx" (without codebehind, but same code), I
get no errors.

Any 1 ??

TIA


-- ws.asmx --
<%@ WebService Language="vb" Codebehind="ws.vb" Class="Service1" %>
--


-- ws.vb --
Imports System
Imports System.Web
Imports System.Web.Services

<WebService(Namespace:="http://127.0.0.1/ws/")> _
Public Class Service1
Inherits WebService

<WebMethod()> _
Public Function Add(ByVal a As Integer, ByVal b As Integer) As
Integer
Return a + b
End Function

End Class
--


-- ws_ok.asmx --
<%@ WebService Language="vb" Class="Service1" %>

Imports System
Imports System.Web
Imports System.Web.Services

<WebService(Namespace:="http://127.0.0.1/ws/")> _
Public Class Service1
Inherits WebService

<WebMethod()> _
Public Function Add(ByVal a As Integer, ByVal b As Integer) As
Integer
Return a + b
End Function

End Class
--
 
You should compile the project first before you can start using it. During
this, all the code-behind pages are compiled into a binary file in the bin
folder. This file contains all the code-behind classes you use in your ASMX
file. Since you probably did not do this, you are receiving this error.
 
You should compile the project first before you can start using it.

Ahh.. okey. So I just can't do it like I do with my
aspx-codebehind-files ?? - only if I put it all in the asmx-file ??


mypage.aspx
--
<%@ Page Language="vb" Inherits="mypage" Src="mypage.vb" %>
--

mypage.vb
--
Imports ....

Public Class mypage
Inherits page

Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
End Sub
End Class
--
 
Back
Top