OperationContext.Current is null in .net core

1.3k views Asked by At

I'm providing a WCF service in my .net core project via SoapCore. In one of the methods, I want to access the SOAP envelope header info. To test that, I've added the following code:

[ServiceContract]
public interface IDataService {
    [OperationContract]
    string TransmitObject(XElement node);
}

// -------------------------------------------------------------------------

public string TransmitObject(XElement node) {
    foreach(var header in OperationContext.Current.IncomingMessageHeaders) {
        Console.WriteLine(header.ToString());
    }

    return JsonConvert.SerializeXNode(node, Formatting.None);
}

However, in this case, the OperationContext.Current attribute is always null. What do I need to change in order to make that work?

0

There are 0 answers