Ask a Question related to ASP.NET Web Services, Design and Development.
-
newbie via DotNetMonster.com #1
xmlns attribute
I am returning xml from a web service. When I look at the response, I notice
that the root element has xmlns="". Why is this and how do I correct this ?
(either get rid of it or fill it in).
re: the web method returns an XmlDocument which I create doing the following :
MemoryStream mem=new MemoryStream();
XmlTextWriter writer=new XmlTextWriter(mem, new System.Text.UTF8Encoding
(false));
--- write the document ---
XmlDocument doc=new XmlDocument();
doc.LoadXml(System.Text.Encoding.UTF8.GetString(me m.ToArray()));
return doc;
newbie via DotNetMonster.com Guest
-
#39505 [NEW]: xpath query failed if root element has xmlns attribute
From: sghnqk at gmail dot com Operating system: linux PHP version: 5.2.0 PHP Bug Type: DOM XML related Bug description: ... -
#38949 [NEW]: Cannot get xmlns value attribute
From: superruzafa at gmail dot com Operating system: Windows XP PHP version: 5.1.6 PHP Bug Type: DOM XML related Bug... -
cellRenderer xmlns problem
I am having a problem figuring out how to get this to work. I have an mxml cell renderer document in a subfolder of a components folder. In the... -
Retrieving XML attribute using XML::XPath::Node::Attribute
Hi I am trying to retrieve an attribute of a particular node from my XML using "XML::XPath::Node::Attribute", but couldn't come across on how to... -
Web Service xmlns tag
Hi guys. We have to develop some web service based our clients requirement. From their specification, they will send us the message request like the... -
Scott M. #2
Re: xmlns attribute
An XML NameSpace (xmlns) is a virtual way to group together related nodes.
You don't want to get rid of it, you should provide a namespace for all the
XML that your web service creates. XML Namespaces take the form of URI's
(most commonly made via URLs), so a namespace would look like:
[url]http://www.YourOrganization.com/SomethingThatDescribesYourWebService[/url].
Although namespaces are written as URLs, the actual URL you come up with
need not be a browsable path on your web server.
Namespaces are one of the core concepts of XML, I strongly suggest you
research them further.
"newbie via DotNetMonster.com" <forum@DotNetMonster.com> wrote in message
news:51F7BAC3A054A@DotNetMonster.com...>
> I am returning xml from a web service. When I look at the response, I
> notice
> that the root element has xmlns="". Why is this and how do I correct this
> ?
> (either get rid of it or fill it in).
>
> re: the web method returns an XmlDocument which I create doing the
> following :
>
>
> MemoryStream mem=new MemoryStream();
> XmlTextWriter writer=new XmlTextWriter(mem, new System.Text.UTF8Encoding
> (false));
>
> --- write the document ---
>
> XmlDocument doc=new XmlDocument();
> doc.LoadXml(System.Text.Encoding.UTF8.GetString(me m.ToArray()));
> return doc;
Scott M. Guest
-
Leslie \(newbie\) via DotNetMonster.com #3
Re: xmlns attribute
Thanks, but's that's not what I asked.
I know what a namespace is and how's it used, my question is: how is this
happening? I created an XmlDocument and I did not add this attribute. It is
being added by the web service (perhaps after serialization?) when the
response is sent back to the client. (a) Why does this happen? (b) how do I
override this? As per your dissertation on namespaces, if it's a core
concept, then a blank namespace isn't going to be very helpful. At the very
least, I need a way to assign a proper value.
Has anyone seen this ( I can't be alone)
fyi
If I try this using GET or POST I don't have the problem. It's only happens
on the response for a SOAP request.
Scott M. wrote:>An XML NameSpace (xmlns) is a virtual way to group together related nodes.
>You don't want to get rid of it, you should provide a namespace for all the
>XML that your web service creates. XML Namespaces take the form of URI's
>(most commonly made via URLs), so a namespace would look like:
>[url]http://www.YourOrganization.com/SomethingThatDescribesYourWebService[/url].
>
>Although namespaces are written as URLs, the actual URL you come up with
>need not be a browsable path on your web server.
>
>Namespaces are one of the core concepts of XML, I strongly suggest you
>research them further.
>>[quoted text clipped - 14 lines]>> I am returning xml from a web service. When I look at the response, I
>> notice>> doc.LoadXml(System.Text.Encoding.UTF8.GetString(me m.ToArray()));
>> return doc;
--
Message posted via [url]http://www.dotnetmonster.com[/url]
Leslie \(newbie\) via DotNetMonster.com Guest
-
Scott M. #4
Re: xmlns attribute
Sorry about that. From the way you phrased your question, it seemed as if you were not aware of what xmlns was.
Anyway, using the XmlDocument class, you can remove the attribute completely (not a good idea) with:
x.DocumentElement.RemoveAttribute("xmlns")
Or, you can set the namespace with:
x.DocumentElement.SetAttribute("xmlns", "http://www.MyCompany.com/myArea")
Good luck!
"Leslie (newbie) via DotNetMonster.com" <forum@DotNetMonster.com> wrote in message news:5200011FCA04D@DotNetMonster.com...>
> Thanks, but's that's not what I asked.
>
> I know what a namespace is and how's it used, my question is: how is this
> happening? I created an XmlDocument and I did not add this attribute. It is
> being added by the web service (perhaps after serialization?) when the
> response is sent back to the client. (a) Why does this happen? (b) how do I
> override this? As per your dissertation on namespaces, if it's a core
> concept, then a blank namespace isn't going to be very helpful. At the very
> least, I need a way to assign a proper value.
>
> Has anyone seen this ( I can't be alone)
>
> fyi
> If I try this using GET or POST I don't have the problem. It's only happens
> on the response for a SOAP request.
>
> Scott M. wrote:>>>An XML NameSpace (xmlns) is a virtual way to group together related nodes.
>>You don't want to get rid of it, you should provide a namespace for all the
>>XML that your web service creates. XML Namespaces take the form of URI's
>>(most commonly made via URLs), so a namespace would look like:
>>[url]http://www.YourOrganization.com/SomethingThatDescribesYourWebService[/url].
>>
>>Although namespaces are written as URLs, the actual URL you come up with
>>need not be a browsable path on your web server.
>>
>>Namespaces are one of the core concepts of XML, I strongly suggest you
>>research them further.
>>>>[quoted text clipped - 14 lines]>>> I am returning xml from a web service. When I look at the response, I
>>> notice>>> doc.LoadXml(System.Text.Encoding.UTF8.GetString(me m.ToArray()));
>>> return doc;
>
> --
> Message posted via [url]http://www.dotnetmonster.com[/url]Scott M. Guest
-
Leslie \(newbie\) via DotNetMonster.com #5
Re: xmlns attribute
Thanks for showing me how to remove the attributes. If I change the
attribute in my method as you showed me, it will keep it. However if I try to
remove it, or change the value to null (just for fun) it just defaults to
xmlns="" (blank) when I look at the response on the client.
It seems that the blank namespace attribute is added after the response is
serialized, if I don't specify one.
Just curious as to why this happens or more precisely, I guess I would like
to know the internal workings of .NET. I would think that a blank namespace
wouldn't be allowed let alone added by .NET.
Scott M. wrote:>Sorry about that. From the way you phrased your question, it seemed as if you were not aware of what xmlns was.
>
>Anyway, using the XmlDocument class, you can remove the attribute completely (not a good idea) with:
> x.DocumentElement.RemoveAttribute("xmlns")
>
>Or, you can set the namespace with:
>
> x.DocumentElement.SetAttribute("xmlns", "http://www.MyCompany.com/myArea")
>
>Good luck!
>>[quoted text clipped - 29 lines]>> Thanks, but's that's not what I asked.
>>>>>> doc.LoadXml(System.Text.Encoding.UTF8.GetString(me m.ToArray()));
>>>> return doc;
--
Message posted via DotNetMonster.com
[url]http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-webservices/200508/1[/url]
Leslie \(newbie\) via DotNetMonster.com Guest



Reply With Quote

