how to use Manespace Property in code behind

R

Rocio

I have a Default.asmx file that contains only this line:

<%@ WebService Language="vb" Codebehind="WebService.vb"
class="MyProgramBS.WebService" %>

All my WEbMethods are in MyProgramBS.WebService: e.g.
<WebMethod()> Public Function CanPayOnline(ByVal loginID As Long) as
Boolean()

When I test this, the default value of the namspace is
http://tempuri.org/

I tried modifying the code in Default.asmx as:
Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="http://www.MyWebSite.net/WebService")>
_
Public Class WebService
Inherits System.Web.Services.WebService

' 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
' Return "Hello World"
'End Function

End Class

but nothing happens. I think it is because I do not write any of my
web methods in the asmx file, but I redirect to WebService.vb . So how
can I change the Namespace this way?
 
R

Rocio Katsanis

Tx. for the reply.
Yes, I know I have to do this, but where? In my Default.asmx.vb file?
Well I put it there, but I do not implement any WebMethod here, but in
another file. What I do in Default.aspx is to redirect the program to
this other file where I implement my WebMethods.

This is what I have:

MySolution (2 projects)
Project
Default.asmx
web.config
Global.asax
ProjectBS
WebService.vb

Default.asmx is empty, but contains a line that redirects it to
ProjectBS.WebService.vb
However, in Default.asmx.vb I put the Namespace as you indicated and as
I did before, and nothing happens.....

Is it because I have the WebMethods in another file?
 
J

Jan Tielens

When you open the CODE of the ASMX page (physically the vb file), you'll see
the code for your web services. Since you are using VB.NET look for Public
Class .... Remember that you must apply this attribute or class level (not
method level) and that attributes in VB.NET are between < and >.
 
R

Rocio Katsanis

OK.

I got it. Since I have implemented the class WebService in another file
(not in my asmx.vb) and this file resides in another project (a class
project), I added the attribute <WebService> to the class in this file:

<System.Web.Services.WebService(Namespace:="http://www.mywebsite.com/Web
Service")> _
Public Class WebService
Inherits System.Web.Services.WebService

End Class

Previously I had a simple Public Class WebService .... in this file, and
the Namespace attribute was in the asmx.vb file.

Tx!
 

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,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top