473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Web Service XmlDocument Parameter

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
1 3606
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Caesare Gentile | last post by:
Suppose I want to write a webservice, where an XML file is loaded in XmlDocument and then a web method is built that would take in an XPath query as a parameter, and a string value. The Xpath...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
1
by: Andy Fish | last post by:
Hi, I would like to send an XML document as a parameter to an asp.net web service. Obviously I could just serialize it and transfer it as a string but that seems a bit of a waste, given that...
3
by: kkao77 | last post by:
I am trying to use schema to validate the data that user sent to my service. How do I achieve that using schema? Do I give schema to the client? or do I write my own schema validation inside web...
14
by: needin4mation | last post by:
I have this in my web service: public XmlDocument GetDataFromDB(string name) { .... do some stuff with name variable..on the database... return the XmlDocument to my datagrid; } Now, in my...
2
by: nit81 | last post by:
Hi Friends, I am trying to call a Java Web Service from .Net using C#. This is a SOAP request that I am making. XmlDocument xmlDoc = new XmlDocument(); ...
15
by: Ludwig | last post by:
What's the best way to pass xml data to a web service: as XmlDocument, or as a string, or....? (the xml data is structured by XSD) Thanks, kind regards, -- Ludwig http://www.coders-lab.be
2
by: =?Utf-8?B?TGlzYUNvbnN1bHQ=?= | last post by:
I have 2 web services and they are on different servers. I am supposed to POST a serialized XML document from one site to the other. I've looked around, but I'm totally confused. Can anyone...
0
by: dthope69 | last post by:
I have a client that is requiring my web service to accept XMLDocument object as input parameter. I had created it initially to accept byte string and it worked fine. However, when changing to a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.