1

Closed

Whitespace at the start of XmlText attributed string parameter is missing in roundtrip

description

I see that the string starting with an empty space on a parameter decorated with XmlText is missing the space on roundtrip to service.

Request:
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" LastName="Rav"><Item> Din</Item></Person>

Please see the space here in <Item> Din</Item> before 'Din'. It is missing in response. It comes as

Response:
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" LastName="Rav"><Item>Din</Item></Person>

I see that the xmlserializer by itself is working fine. Even objectcontent is also by itself working fine but not when HttpClient sending the message to service.

file attachments

Closed May 21, 2012 at 11:00 PM by HongmeiG
This is the same issue posted in the WCF forum. Once that is fixed, this issue will not repro any more.

comments

pbolduc wrote May 19, 2012 at 6:01 PM

The above issue appears to be the same as posted on the WCF forum http://social.msdn.microsoft.com/Forums/eu/wcf/thread/a5e1dd95-5d85-4eab-a644-ed89b8d47cc6

Does the white space get preserved if you specify xml:space="preserve" ? Or in an xsd, you use:

<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>

See: "Restrictions on Whitespace Characters" at http://www.w3schools.com/schema/schema_facets.asp

<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" LastName="Rav"><Item xml:space="preserve"> Din</Item></Person>