By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,636 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,636 IT Pros & Developers. It's quick & easy.

Web Service XmlDocument Parameter

P: n/a
I have a web service that takes an XmlDocument as a parameter, performs some
processing on it, and saves it to a database. The web service signature
looks similar to this:

public void SaveDocument(XmlDocument doc)
{
//Method logic omitted
}

The web service worked great in .net 1.1, but upon upgrading to .net 2.0 IIS
began responding with "The request failed with HTTP status 400: Bad Request."
After doing some research, I discovered that the problem is that the
XmlDocument has named character entities. The document might look this this,
for example:

<example>
<text>100° is hot</text>
</example>

Part of the processing that the web service does is to look for these named
character entities and convert them to XML friendly numeric character
entities before saving it to the database. The stored document therefore
looks like this:

<example>
<text>100° is hot</text>
</example>

I've gotten around the problem at the moment by changing the parameter to a
string type and then loading it into an XmlDocument object in the web service
like this:

public void SaveDocument(string docstring)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlDocumentFragment fragment =
doc.CreateDocumentFragment();
fragment.InnerXml = docstring;
doc.AppendChild(fragment);

//Method logic omitted
}

Did .net 1.1 illegally allow the named character entity in the XmlDocument
parameter, or is this a problem with .net 2.0? Is there a better workaround
for this problem than converting the doc parameter to a string and coercing
it to an XmlDocument with the XmlDocumentFragment object?

Jan 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
It seems as though the entity was resolved by the system when I posted, so
let me follow up to make it clear. The passed document looks like this:

<example>
<text>100&deg; is hot</text>
</example>
"Joe Monnin" wrote:
I have a web service that takes an XmlDocument as a parameter, performs some
processing on it, and saves it to a database. The web service signature
looks similar to this:

public void SaveDocument(XmlDocument doc)
{
//Method logic omitted
}

The web service worked great in .net 1.1, but upon upgrading to .net 2.0 IIS
began responding with "The request failed with HTTP status 400: Bad Request."
After doing some research, I discovered that the problem is that the
XmlDocument has named character entities. The document might look this this,
for example:

<example>
<text>100° is hot</text>
</example>

Part of the processing that the web service does is to look for these named
character entities and convert them to XML friendly numeric character
entities before saving it to the database. The stored document therefore
looks like this:

<example>
<text>100° is hot</text>
</example>

I've gotten around the problem at the moment by changing the parameter to a
string type and then loading it into an XmlDocument object in the web service
like this:

public void SaveDocument(string docstring)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlDocumentFragment fragment =
doc.CreateDocumentFragment();
fragment.InnerXml = docstring;
doc.AppendChild(fragment);

//Method logic omitted
}

Did .net 1.1 illegally allow the named character entity in the XmlDocument
parameter, or is this a problem with .net 2.0? Is there a better workaround
for this problem than converting the doc parameter to a string and coercing
it to an XmlDocument with the XmlDocumentFragment object?

Jan 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.