Re: namespace?



To be honest I don't care for XML. It's too verbose. I'd have stuck with comma delimited or fixed width files but it all depends on the application. I think it's a bit funny that the new MS stuff, I forget the name maybe it was WCF?, was almost back to comma delimited and they talked about cutting down on the data being sent across the net in comparison to XML.


Scott M. wrote:
No problem CT - - You are not alone when it comes to getting over the confusion of using URL's as namespace names. My company is an IT training company and whenever I am teaching XML, this issue winds up being the single biggest source of confusion. But, once you get your head around the idea, other things become much clearer.

Good luck!

-Scott


"cj" <cj@xxxxxxxxxxxxx> wrote in message news:OBkDFLFWIHA.748@xxxxxxxxxxxxxxxxxxxxxxx
Thanks very much Scott. That's the kind of explanation I wish I had on so many things. Honestly I think if the standard for web service namespaces was ACME/employees/HR instead of http://www.ACME.com/employees/HR it would have made more sense to me as it doesn't carry the connotation that it's a web address. I would have understood it much quicker and I'm probably not the only person who finds it confusing. But that's ok. Now that I understand it's fine.

BTW, I went to a Microsoft Seminar and the speaker said he wasn't going to talk about AJAX since unless we had been living under a rock for the past 3 years we already knew about that. Hey I use AJAX all the time on my kitchen counters! Of course with my great understanding of the lingo the seminar went quite well. ;)

Well I've got to go put some things in order now. Oh, sorry, I mean I've go to marshal some things now.

Thanks again,
CJ


Scott M. wrote:
"cj" <cj@xxxxxxxxxxxxx> wrote in message news:eaqL%23H7VIHA.4440@xxxxxxxxxxxxxxxxxxxxxxx
Yes, that helps. Making a namespace look like a web address is just asking for confusion IMHO but that's life.
What you need to understand is that using what looks like a URL for a namespace name is not directly related to .NET at all and is also not done just for web service use.

It is an XML standard per the World Wide Web Consortium (the W3C). The reason for needing namespaces in XML is because the very nature of XML allows you to make up tag and attribute names yourself based on the data you will be passing. If 2 departments within a single company were to be using XML to represent employee data (for just their department), they each might inadvertently use the same tag names and/or attribute names. Now, if those two lists of XML were to get mixed up, it would be very hard to separate who's data is who's - - namespaces are needed to prevent this from occuring (because although the tag names might be the same, the xmlns="" value would be different).

Now, you may ask "Ok, that makes sense, buy why use URL's and not some other identifier?". Well, what if the two departments were "Human Resources" and "Accounts Payable", couldn't they just use "HR" and "AP" as the namespace names? Perhaps, but what happens if this company were to merge with another company who is also using XML for just the same purpose and that company is most likely going to have Human Resources and Accounts Payable departments as well. If the two companies had been using "HR" and "AP" as their namespace qualifiers, there would be no way to tell who's data was who's.

This is why namespaces are generally specified using URL's, because each company/organization on the planet is guaranteed to have a unique URL and so in the first senario above, the namespaces could be:

http://www.ACME.com/employees/HR
http://www.ACME.com/employees/AP

And, those namespaces would keep, not only those two departments XML data separate, but when the new company gets merged with ACME, we still can keep it all straight because the new company's namespaces would look like this:

http://www.OtherCompany.com/employees/HR
http://www.OtherCompany.com/employees/AP

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?
No. Again, namespaces are not actually resolved by any software, they just serve as names to group related XML data. As in my example above, it could be very confusing if your data and my data got mixed up. Namespaces are not required in all uses of XML because sometimes making "groups" of XML isn't really necessary, but with web services, they are because there are many services out there and different services can still result in similar XML, so we need to keep each service's XML separate from another's.

Does the client know the namespace before it calls the service?
Yes. The proxy classes that are built by Visual Studio (usually hidden files in the Solution Explorer) will have knowledge of the service namespace.

Perhaps it does and then it waits for a response to come that says it's from that web service.
No. Again, namespaces are just strings that identify a group of XML. They aren't used in web services in this way.

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.
True, but your missing the bigger point. Although it *may* not cause a problem if two entities use the same namespace, the fact is that it *could* and to eliminate the possibility, we make sure that different services use different namespaces. It's more of a programming standard than a programming issue.

-Scott

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@xxxxxxxxxxxxxxxxxxxxxxx
I'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
?



.



Relevant Pages

  • Re: namespace?
    ... Namespaces are used in XML (which is the format that your web service ... an XML namespace should start with the ACTUAL URL of your ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: XmlSerializer: deserialize against xsd generated class
    ... If there are 5 namespaces in the XML do I need to add a namespace for each ... I did find a code snippet that removes the "empty" nodes ... public partial class Request_TypeMessageTypeFieldTag4000 { ...
    (microsoft.public.dotnet.xml)
  • Re: namespace?
    ... confusion of using URL's as namespace names. ... Honestly I think if the standard for web service namespaces ... It is an XML standard per the World Wide Web Consortium. ... reason for needing namespaces in XML is because the very nature of XML ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: namespace?
    ... just for web service use. ... It is an XML standard per the World Wide Web Consortium. ... reason for needing namespaces in XML is because the very nature of XML ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: getting rid of NS0 (name space) in xml tags
    ... (it's quite strange, cose, the namespaces are one of the main part of XMl) ... It's the parser's job to bother with namespases and prefixes. ... BTW BizTalk doesn't work well with xml-messages without namespaces. ...
    (microsoft.public.biztalk.general)