开发者

Send information in Soap Header to WCF service in C#

i want a web application to create a service reference to my WCF service, insert information to the header of the soap call and call my WCF method.

i read about MessageContract attribute and declared one in the interface file:

[MessageContract]
public class BasicServiceHeader
{
    [MessageHeader]
    public string myString;
}

my WCf interface is:

   [ServiceContract]
public interface IBasicService
{

  开发者_如何转开发  [OperationContract]       
    [WebGet(UriTemplate = "GetData?value={value}")]     // Add support for HTTP GET Requests
    string GetData(int value);}

i don't want the BasicServiceHeader to be passed as a parameter of GetData function , i want to keep the function as it is and to extract the BasicServiceHeader inside the function, can i do that ?


Client side, you can pass a header prior invoking the operation:

MessageHeader messageHeader = MessageHeader.CreateHeader(_headerName, _headersNameSpace, _headerValue);
OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader);

and extract it using FindHeader service side

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜