473,399 Members | 3,832 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,399 software developers and data experts.

escapeOutput and webmethod

sd
Hello All,
I aplogize if this has already been answered however I
couldn't find anything related to this...

I have bunch of webservices written in vb.net returning
native data types, due to constraints of the client I need
to return data that has been output escaped i.e. when a
string response is returned back by the service it
automatically converts & to amp; and the other reserved
chracters, in this case I don't want the conversion to
happen.
Thanks
sd
Nov 12 '05 #1
3 2640

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?

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"sd" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Hello All,
I aplogize if this has already been answered however I
couldn't find anything related to this...

I have bunch of webservices written in vb.net returning
native data types, due to constraints of the client I need
to return data that has been output escaped i.e. when a
string response is returned back by the service it
automatically converts & to amp; and the other reserved
chracters, in this case I don't want the conversion to
happen.
Thanks
sd

Nov 12 '05 #2
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-----

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'dhave invalid Xml! Characters like the anglebrackets ARE ONLY ALLOWED inelements, nowhere else unless you embed them in a CDATA section.
Is that what you are looking for?

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"sd" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
Hello All,
I aplogize if this has already been answered however I couldn't find anything related to this...

I have bunch of webservices written in vb.net returning
native data types, due to constraints of the client I need to return data that has been output escaped i.e. when a
string response is returned back by the service it
automatically converts & to amp; and the other reserved
chracters, in this case I don't want the conversion to
happen.
Thanks
sd

.

Nov 12 '05 #3
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.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

[0]
http://www.gotdotnet.com/Community/U...4-e916ebc4159c

<an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
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-----

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?

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"sd" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl...
Hello All,
I aplogize if this has already been answered however I couldn't find anything related to this...

I have bunch of webservices written in vb.net returning
native data types, due to constraints of the client I need to return data that has been output escaped i.e. when a
string response is returned back by the service it
automatically converts & to amp; and the other reserved
chracters, in this case I don't want the conversion to
happen.
Thanks
sd

.

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alin Popovici | last post by:
Hi! I have this problem. I am sending as a parameter for a webmethod a string containing '\r\n' sequences. For some reason, when I debug my webmethod, the paramter is received with the carriage...
24
by: Joseph Geretz | last post by:
Up to this point, our application has been using Windows File Sharing to transfer files to and from our application document repository. This approach does not lend itself toward a secure...
2
by: Peter McEvoy | last post by:
Folks, I've been building a Webservice API for a contract that will be exposed to the internet at large. There are two endpoints, and each endpoint contains a number of webmethods. Every...
1
by: spicyz | last post by:
I'm receiving an exception when my webmethod exits after opening/closing an Access database. I can reproduce this easily enough by creating a new default ASP .NET Web Service in VS.NET 2003. ...
5
by: John | last post by:
Hi Is it possible to pass a whole record to a webmethod? How? Thanks Regards
3
by: Khurram | last post by:
Hi, Firstly, I will apologise now if I have posted in the wrong discussion group. Please let me know if I have for future reference. Below is the code to a WebMethod that is querying an Access...
2
by: jojoba | last post by:
Hello to all! I have a fairly simple webservice running in asp.net ajax under c# (vs 2008). I built the service and it runs just dandy when i test it by itself in visual studio. However, to...
2
by: John | last post by:
I'm calling the Webmethod from JS and at the end of the function I would like to do a a ListViewBillable.DataBind() in the Webmethod, calling a postback from JS is not rendering the correct...
0
by: anithaapr05 | last post by:
Dear All, I have try to call the webmethod inside a master page browser close javascript function.It not working. This is my scriptcode: function BrowserClose() { var getValues =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.