Question

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 ?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top