當我向一個restful wcf服務進行標準的Get Request調用時,它將返回一個內容類型爲「application/xml」的應用程序。供應商要求我們發送內容類型爲「text/xml」的內容。如何在wcf中切換這個?它是一個屬性?text/xml從休息中返回調用
的調用是這樣的:
[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;
}
}
HttpClient的包括在WCF休息初學者工具包預覽2 http://aspnet.codeplex.com/releases/view/24644 –
@Joey那了HTTPClient不再支持。有一個新的http://wcf.codeplex.com –
謝謝。似乎WCF中的REST堆棧不斷變化......忘記了Glen接管了它。 –