Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > how to use Manespace Property in code behind

Reply
Thread Tools

how to use Manespace Property in code behind

 
 
Rocio
Guest
Posts: n/a
 
      05-25-2004
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?
 
Reply With Quote
 
 
 
 
Jan Tielens
Guest
Posts: n/a
 
      05-25-2004
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
}

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


"Rocio" <> schreef in bericht
news: m...
> 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/WebServ
ice")>
> _
> 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?



 
Reply With Quote
 
 
 
 
Rocio Katsanis
Guest
Posts: n/a
 
      05-25-2004

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?



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Jan Tielens
Guest
Posts: n/a
 
      05-26-2004
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 >.

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


"Rocio Katsanis" <> schreef in bericht
news:%...
>
> 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?
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Rocio Katsanis
Guest
Posts: n/a
 
      05-26-2004
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!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Jan Tielens
Guest
Posts: n/a
 
      05-26-2004
Np! Glad I could help!

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


"Rocio Katsanis" <> schreef in bericht
news:%...
> 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!
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
ASP.NET 2.0: To use or not to use code behind? pedestrian via DotNetMonster.com ASP .Net 5 09-28-2006 06:19 AM
Code-Behind Pain in the Behind! Daniel Manes ASP .Net 11 06-10-2005 09:47 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57