Created
July 6, 2016 16:15
-
-
Save BenjaminAdams/0956df5c456354a65dabea8bdd108a88 to your computer and use it in GitHub Desktop.
How to add HTTP headers in a WCF service call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void PerformSoapCall() { | |
using (var client = new SomeClient()) | |
using (new OperationContextScope(client.InnerChannel)) | |
{ | |
HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); | |
requestMessage.Headers["Authorization"] = "Basic 521vYmFsUGF5bWVudEdhdGV3YXk6R1BHMTIz22=="; | |
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; | |
var res = await client.SomethingAsync(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment