0

i wrote one method for getting details.in rest client getting response like this.

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">&lt;Meetings&gt;&#xD;
&lt;Meeting&gt;&#xD;
&lt;Id&gt;1&lt;/Id&gt;&#xD;
&lt;Name&gt;Meeting1&lt;/Name&gt;&#xD;
&lt;Place&gt;SR Nagar&lt;/Place&gt;&#xD;
&lt;Time&gt;12/4/12 12:30pm&lt;/Time&gt;&#xD;
&lt;/Meeting&gt;&#xD;
&lt;Meeting&gt;&#xD;
&lt;Id&gt;2&lt;/Id&gt;&#xD;
&lt;Name&gt;Meeting2&lt;/Name&gt;&#xD;
&lt;Place&gt;Begumpet&lt;/Place&gt;&#xD;
&lt;Time&gt;12/4/12 1:00pm&lt;/Time&gt;&#xD;
&lt;/Meeting&gt;&#xD;
&lt;/Meetings&gt;&#xD;
</string>

in rendered html getting proper.

<Meetings> <Meeting> <Id>1</Id> <Name>Meeting1</Name> <Place>SR Nagar</Place> <Time>12/4/12 12:30pm</Time> </Meeting> <Meeting> <Id>2</Id> <Name>Meeting2</Name> <Place>Begumpet</Place> <Time>12/4/12 1:00pm</Time> </Meeting> </Meetings>

How to handle it in code in wcf to avoid <

2 Answers 2

3

Your service operation returns string and you are writing XML to that string. It will always look like that and browser shows it correctly only because it hides string tag and unescapes the content.

To return real XML you must not use string as return value. Try to use for example XElement.

Sign up to request clarification or add additional context in comments.

Comments

1

In your [OperationContract] method, instead of returning a string, return an array of Meeting objects. The Meeting class should contain the properties you'd like to return:

[DataContract]
public class Meeting
{
    [DataMember]
    public int Id { get; set; }
    [DataMember]
    public string Name { get; set; }
    [DataMember]
    public string Place { get; set; }
    // etc...
}

If you're using .NET 4.0 and up, the [DataContract] and [DataMember] attributes are not required.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.