Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / May 2004

Tip: Looking for answers? Try searching our database.

how to use Manespace Property in code behind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rocio - 25 May 2004 19:15 GMT
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?
Jan Tielens - 25 May 2004 21:45 GMT
The TempUri namespace is the namespace for the XML soap message! You can
control this by using the WebService attribute, for example:

[WebService(Namespace="http://microsoft.com/webservices/")]
public class MyWebService {
   // implementation
}

Signature

Greetz
Jan
________________
Read my weblog: http://weblogs.asp.net/jan

> I have a Default.asmx file that contains only this line:
>
[quoted text clipped - 10 lines]
> I tried modifying the code in Default.asmx as:
> Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="http://www.MyWebSite.net/WebServ
ice")>
> _
> Public Class WebService
[quoted text clipped - 18 lines]
> web methods in the asmx file, but I redirect to WebService.vb . So how
> can I change the Namespace this way?
Rocio Katsanis - 25 May 2004 22:06 GMT
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?
Jan Tielens - 26 May 2004 17:06 GMT
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 >.

Signature

Greetz
Jan
________________
Read my weblog: http://weblogs.asp.net/jan

> Tx. for the reply.
> Yes, I know I have to do this, but where? In my Default.asmx.vb file?
[quoted text clipped - 18 lines]
>
> Is it because I have the WebMethods in another file?
Rocio Katsanis - 26 May 2004 17:55 GMT
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!
Jan Tielens - 26 May 2004 22:09 GMT
Np! Glad I could help!

Signature

Greetz
Jan
________________
Read my weblog: http://weblogs.asp.net/jan

> OK.
>
[quoted text clipped - 13 lines]
>
> Tx!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.