WCF service contract and data contract
I have following code
[ServiceContract(Namespace = "http://www.myweb.com/prod")]
public interface IBaseService
{
[OperationContract]
public string GetName(IDMessageContract ID)
}
[ServiceContract(Namespace = "http://www.myweb.com/prod/child")]
public interface IC开发者_如何学ChildService : IBaseService
{}
public class BaseService
{ public string GetName(IDMessageContract ID)}
public class ChildService: IChildService
{}
[MessageContract]
public class IDMessageContract
{
public string ID{get;set;}
}
In above scenario I need the GetName method SOAP header containing the namespace "http://www.myweb.com/prod/child"
If you need SOAP header with specified namespace you must specify that header in message contract and use its Namespace property. Something like:
[MessageContract]
public class IDMessageContract
{
[MessageHeader(Namespace="http://www.myweb.com/prod/child")]
public string MyHeader { get; set;}
[MessageBodyMember]
public string ID{get;set;}
}
精彩评论