Created
December 5, 2016 12:18
-
-
Save hanssens/700862b3338866b092bf4c7dd4db691b to your computer and use it in GitHub Desktop.
BindingFactory - Helpers for adding WsHttpBinding/WsHttpsBinding to dotnet core projects.
This file contains hidden or 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 static class BindingFactory | |
{ | |
/// <summary> | |
/// A poor man's implementation for dotnet-core support of WsHttpBinding (plain, http). | |
/// </summary> | |
/// <param name="endpointAddress">Full http endpoint address.</param> | |
public static System.ServiceModel.Channels.Binding CreateWsHttpBinding(string endpointAddress) | |
{ | |
var result = new System.ServiceModel.Channels.CustomBinding(); | |
var textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement(); | |
result.Elements.Add(textBindingElement); | |
var httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement | |
{ | |
AllowCookies = true, | |
MaxBufferSize = int.MaxValue, | |
MaxReceivedMessageSize = int.MaxValue | |
}; | |
result.Elements.Add(httpBindingElement); | |
return result; | |
} | |
/// <summary> | |
/// A poor man's implementation for dotnet-core support of WsHttpsBinding (secured, https). | |
/// </summary> | |
/// <param name="endpointAddress">Full https endpoint address.</param> | |
public static System.ServiceModel.Channels.Binding CreateWsHttpsBinding(string endpointAddress) | |
{ | |
var result = new System.ServiceModel.Channels.CustomBinding(); | |
var textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement(); | |
result.Elements.Add(textBindingElement); | |
var httpsBindingElement = new System.ServiceModel.Channels.HttpsTransportBindingElement | |
{ | |
AllowCookies = true, | |
MaxBufferSize = int.MaxValue, | |
MaxReceivedMessageSize = int.MaxValue | |
}; | |
result.Elements.Add(httpsBindingElement); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually inspired by the following two dotnet WCF issues: