Reputation: 1863
i wrote one method for getting details.in rest client getting response like this.
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><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>
</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 <
Upvotes: 0
Views: 839
Reputation: 16141
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.
Upvotes: 1
Reputation: 364409
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
.
Upvotes: 3