468,272 Members | 2,040 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

Carriage Return in WebMethod parameters

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 return characters ('\r')
stripped. Can someone try this by creating a simple
webmethod that takes a string as a parameter and returns
the same string back. On the client, create a proxy, call
the webmethod and pass: "bla\r\nbla". If you put a bkpoint
inside the webmethod, you will see the string received
does not contain '\r' characters.

[AdvancedDebugging]
I also created a SOAP extension and verified the message
that is received on the server in the AfterDeserialize
stage, and to my surprise, the message contains here the
carriage return characters.

I am using the v1.1.4322 Framework on the client and
server.

Please HELP!

:)

Alin
Nov 12 '05 #1
2 5490
The problem is most likely based on the fact that the response is read in
using the XmlSerializer, which assumes insignificant whitespace by default.
You would have to change the WhitespaceHandling property of the
XmlTextReader that deserializes the response from the web serivce, but I
don't think there is a way to access that XmlTextReader.

If you really need significant whitespace, then try to return CDATA section
rather than a string. Maybe this thread [0] helps.

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

[0]
http://groups.google.com/groups?thre...TNGP12.phx.gbl

"Alin Popovici" <an*******@discussions.microsoft.com> wrote in message
news:4c****************************@phx.gbl...
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 return characters ('\r')
stripped. Can someone try this by creating a simple
webmethod that takes a string as a parameter and returns
the same string back. On the client, create a proxy, call
the webmethod and pass: "bla\r\nbla". If you put a bkpoint
inside the webmethod, you will see the string received
does not contain '\r' characters.

[AdvancedDebugging]
I also created a SOAP extension and verified the message
that is received on the server in the AfterDeserialize
stage, and to my surprise, the message contains here the
carriage return characters.

I am using the v1.1.4322 Framework on the client and
server.

Please HELP!

:)

Alin

Nov 12 '05 #2
Hello Alin,
Unfortunately this is behavior by design for SOAP XML sterilizer.

According to the XML spec http://www.w3.org/TR/REC-xml#sec-line-ends
(section 2.11 End-of-Line Handling) all the \r\n character sequences should
be translated to single \r character.

As a workaround you can try to encode strings you are sending using base64
or similar encoding or parse them back and replace \r to \r\n after
de-serialization is done.

--
Thanks,
Eugene
-------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.

"Alin Popovici" <an*******@discussions.microsoft.com> wrote in message
news:4c****************************@phx.gbl...
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 return characters ('\r')
stripped. Can someone try this by creating a simple
webmethod that takes a string as a parameter and returns
the same string back. On the client, create a proxy, call
the webmethod and pass: "bla\r\nbla". If you put a bkpoint
inside the webmethod, you will see the string received
does not contain '\r' characters.

[AdvancedDebugging]
I also created a SOAP extension and verified the message
that is received on the server in the AfterDeserialize
stage, and to my surprise, the message contains here the
carriage return characters.

I am using the v1.1.4322 Framework on the client and
server.

Please HELP!

:)

Alin

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Alin Popovici | last post: by
6 posts views Thread by Bruce W.1 | last post: by
2 posts views Thread by Matt Mercer | last post: by
reply views Thread by ajfish | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.