0
我有以下WCF包装调用REST服务:如何使用OperationContract从POST请求中捕获响应头?
[DataContract]
public class InterestingResponse : IExtensibleDataObject
{
[MessageHeader(Name="x-interesting-id")]
public string InterestingId { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
[ServiceContract()]
public interface IManagement
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = @"somePathHere")]
InterestingResponse DoInteresting();
}
的请求被发送到服务,并成功完成。 HTTP响应具有空的主体和x-interesting-id
标头。我希望客户端代码返回InterestingResponse
的实例,并将InterestingId
设置为响应中的值x-interesting-id
。
一旦IManagement.DoInteresting()
在客户端返回空引用返回,因为好吧,响应是空的,没有任何反序列化,我猜。
我将如何返回一个对象,而将头部值反序列化为对象成员?