N
news.microsoft.com
I have exactly the same problem but instead the solution is directed to
compact framework.
I decided to use DOM. Using the XmlDocument class I created all the nodes
(envelope, body, etc) and sent it to a stream with the XmlDocument.Save
method. However, an exception was returned saying that it "Cannot use a
prefix with an empty namespace".
I decided to look a bit better and I came upon the InnerXml property of the
current object (XmlDocument). It had the following value (since InnerXml is
a string property it is full of escape characters, don't mind those):
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\"
xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">
<s:Body>
<u:SetTarget xmlns:u=\"urn:schemas-upnp-org:service:SwitchPower:1\">
<newTargetValue>1</newTargetValue>
</u:SetTarget>
</s:Body>
</s:Envelope>
What seems to be the problem? Is it the s:Body element? I already read
documents about XML namespaces and it seems fine to me. There is no
namespace since it inherits it from the above node (s:Envelope).
Actually I think that namespace was removed by XmlDocument since I created
the Body node with a namespace (the same as the Envelope's).
Cheers!
Pedro
compact framework.
I decided to use DOM. Using the XmlDocument class I created all the nodes
(envelope, body, etc) and sent it to a stream with the XmlDocument.Save
method. However, an exception was returned saying that it "Cannot use a
prefix with an empty namespace".
I decided to look a bit better and I came upon the InnerXml property of the
current object (XmlDocument). It had the following value (since InnerXml is
a string property it is full of escape characters, don't mind those):
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\"
xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">
<s:Body>
<u:SetTarget xmlns:u=\"urn:schemas-upnp-org:service:SwitchPower:1\">
<newTargetValue>1</newTargetValue>
</u:SetTarget>
</s:Body>
</s:Envelope>
What seems to be the problem? Is it the s:Body element? I already read
documents about XML namespaces and it seems fine to me. There is no
namespace since it inherits it from the above node (s:Envelope).
Actually I think that namespace was removed by XmlDocument since I created
the Body node with a namespace (the same as the Envelope's).
Cheers!
Pedro