Re: namespace?
- From: cj <cj@xxxxxxxxxxxxx>
- Date: Tue, 15 Jan 2008 15:05:35 -0500
Yes, that helps. Making a namespace look like a web address is just asking for confusion IMHO but that's life.
So what I'm still wondering is why would it matter if you and I both use the same namespace--or would it? It's not actually telling the client where to send the request is it? Does the client know the namespace before it calls the service? Perhaps it does and then it waits for a response to come that says it's from that web service. In which case it wouldn't matter if both of us used the same namespace as long as a client wasn't requesting data from both of us in which case it would get confused on responses.
Scott M. wrote:
A "namespace" looks like a URL, but it is not. In this case "tempuri" stands for "temporary URI", meaning that it is dummy data that you are supposed to change..
Namespaces are used in XML (which is the format that your web service sends/receives data) to organize/group XML tags and attributes. This is conceptually the same as how namespaces are used in .NET - - to organize/group classes. The difference being that in .NET, the syntax uses dot notation (i.e. System.Web.UI) and in XML, namespaces use URI (uniform resource indicators), such as "http://www.something.com". Although they look like URL's, they are not and they are not meant to be resolved - - they are just names that you make up to keep your XML tags and attributes used by your web service organized and marked as belonging to you.
Generally, an XML namespace should start with the ACTUAL URL of your company/organization, but again, not so that they can be browsed to, but because it is highly unlikely that anyone else on the planet would start their XML namespaces with your company/organization URL. After the beginning of the URL, you generally add something else that defines what your web serivice is. For example, my company is Technical Training Solutions and my URL is http://TechTrainSolutions.com. If I were making a web service that retrieves course ID's from a database, I might use the following to indicate that all the xml coming back from the service be "grouped" in the same namespace.
<System.Web.Services.WebService(Namespace:="http://www.TechTrainSolutions.com/services/courseID")>
After adding such a namespace, you'll be able to actually see it used when you examine the results of your web service call. You'd see something like this:
<string xmlns="http://www.TechTrainSolutions.com/services/courseID">012-4A</string>
Hope this helps.
-Scott
"cj" <cj@xxxxxxxxxxxxx> wrote in message news:usFByT5VIHA.1184@xxxxxxxxxxxxxxxxxxxxxxxI'm still not getting this. Namespace:="http://tempuri.org/" looks like a web address and I've opend it but don't understand what it's saying. Can you try again to explain what a namespace does and why my web service needs to refer to one?
Also I think this has something to do with the WebMethodAttribute that we are discussing in my other post. Am I correct?
Steven Cheng[MSFT] wrote:Hi Cj,
As for the following attribute:
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> It is used to describe and decorate your webservice service class(applied on class level). Certainly, you can use the same one for C# code, they're the same. Also you can find more properites(that you can set on this attribute for your service class): #WebServiceAttribute Class
http://msdn2.microsoft.com/en-us/library/system.web.services.webserviceattri
bute.aspx
In addition, to better understand its usage, you can visit the service's WSDL document (view through yourservice.asmx?WSDL url). Change the attribute setting and refresh the WSDL document to see the changes.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Date: Fri, 11 Jan 2008 15:07:05 -0500
From: cj <cj@xxxxxxxxxxxxx>
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
Subject: namespace?
Newsgroups: microsoft.public.dotnet.framework.webservices
What does the line
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
do in the example below?
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1
_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
And why don't I see a similar line in the C# example at
http://dotnetjunkies.com/Tutorial/4D13CEFA-D0FD-44BE-8749-8D17B5757564.dcik
?
- Follow-Ups:
- Re: namespace?
- From: Scott M.
- Re: namespace?
- References:
- namespace?
- From: cj
- RE: namespace?
- From: Steven Cheng[MSFT]
- Re: namespace?
- From: cj
- Re: namespace?
- From: Scott M.
- namespace?
- Prev by Date: Re: namespace?
- Next by Date: different way of writing a web service?
- Previous by thread: Re: namespace?
- Next by thread: Re: namespace?
- Index(es):
Relevant Pages
|
Loading