gleasonomicon
gleasonomicon

Reputation: 1089

text/xml return from rest call

When I make a standard Get Request call to a restful wcf service it returns with a content type of "application/xml". A vendor is asking we send with a content type of "text/xml". How do I switch this in wcf? Is it an attribute?

The call is this:

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, Namespace = "")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document, Use=OperationFormatUse.Literal)]
public class Player
{

    [WebGet(UriTemplate = "{id}")]
    public string GetTestDetailsRequest(string id)
    {
        TestService.TestServiceClient testServiceClient = new TestServiceClient();
        string xml = testServiceClient.GetTestDetailsRequest(Guid.Parse(id));
        return xml;
    }
}

Upvotes: 0

Views: 679

Answers (2)

Randy Levy
Randy Levy

Reputation: 22655

You can override the content type:

WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";

Upvotes: 0

Darrel Miller
Darrel Miller

Reputation: 142004

Don't try and use WCF to call RESTful services. Just use HttpWebRequest or HttpClient, that way you will have control over your request.

Upvotes: 1

Related Questions