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.GetTestDetails开发者_C百科Request(Guid.Parse(id));
return xml;
}
}
Don't try and use WCF to call RESTful services. Just use HttpWebRequest or HttpClient, that way you will have control over your request.
You can override the content type:
WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
精彩评论