I am not quite sure I'm following. It appears you skipped a sentence or so.
In genereal though, you always want the escaping to happen, otherwise you'd
have invalid Xml! Characters like the anglebrackets ARE ONLY ALLOWED in
elements, nowhere else unless you embed them in a CDATA section.
Is that what you are looking for?

Signature
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
Thx! for the reply. I agree that the reserved characters
must be output escaped, however if the webmethod were to
return a string, how would I specify that its CDATA.
e.g.
<webmethod....>
public function showString( byval var as string) as string
return var
end function
now if var contains any of the special characters, they
are already xml escaped for you, I don't want that to be
xml escaped instead I would want to put that in CDATA.
Thanks
sd
>-----Original Message-----
>
[quoted text clipped - 22 lines]
>
>.
Christoph Schittko [MVP] - 24 Dec 2003 23:18 GMT
Sd,
If you want the CDATA section directly inside the response node like this:
<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetCdataResponse xmlns="http://tempuri.org/"><![CDATA[This contains
<markup> & some other gunk </markup>]]></GetCdataResponse>
</soap:Body>
</soap:Envelope>
you could define your WebMethod like this:
[WebMethod()]
[return: XmlAnyElement()]
public XmlCDataSection GetCdata()
{
XmlCDataSection cdata = new XmlDocument().CreateNode( XmlNodeType.CDATA,
"MyCDataNode", "" ) as XmlCDataSection;
cdata.Data = "POST ONLY This contains <markup> & some other gunk
</markup>";
return cdata;
}
Note that you can't test this from the browser, you'll have to use a tool
like Web Services Studio [0] to check the actual method response. The
browser submits the Request via am HTTP GET request which causes ASP.NET to
omit the <Envelope> and <Body> tags, which then in turn results in the
attempt to start a CDATA node as the first node in an Xml document, which
results in an exception.
Web Services Studio will submit the request via an HTTP POST, just like a
web services proxy generated by Visual Studio .NET and you can verify that
the response.

Signature
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
[0]
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=65a1d4ea-
0f7a-41bd-8494-e916ebc4159c
> Thx! for the reply. I agree that the reserved characters
> must be output escaped, however if the webmethod were to
[quoted text clipped - 46 lines]
> >
> >.