当我使用实用创建的 CustomBinding 时,我不断收到以下异常。
寻址版本“AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)”不支持添加 WS-Addressing 标头。
有没有办法解决这个问题?
private static CustomBinding CreateCustomBinding(bool useHttps)
{
BindingElement security;
BindingElement transport;
if (useHttps)
{
security = SecurityBindingElement.CreateSecureConversationBindingElement(
SecurityBindingElement.CreateUserNameOverTransportBindingElement());
transport = new HttpsTransportBindingElement
{
MaxBufferPoolSize = 2147483647,
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647,
};
}
else
{
security = SecurityBindingElement.CreateSecureConversationBindingElement(
SecurityBindingElement.CreateUserNameForSslBindingElement(true));
transport = new HttpTransportBindingElement
{
MaxBufferPoolSize = 2147483647,
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647,
};
}
var encoding = new MtomMessageEncodingBindingElement
{
MaxReadPoolSize = 64,
MaxWritePoolSize = 16,
MaxBufferSize = 2147483647,
MessageVersion = MessageVersion.Soap11,
WriteEncoding = System.Text.Encoding.UTF8
};
//var encoding = new TextMessageEncodingBindingElement();
var customBinding = new CustomBinding();
customBinding.Elements.Add(security);
customBinding.Elements.Add(encoding);
customBinding.Elements.Add(transport);
return customBinding;
}