我需要以编程方式创建wsHttpBinding
(自定义绑定),为此,我需要以下配置:
<binding name="ws_IMembershipService_TransportWithMessageCredential_Username" messageEncoding="Text" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="true" maxBufferPoolSize="524288" maxReceivedMessageSize="10000000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
</binding>
在C#中此配置等效于什么?
答案 0 :(得分:0)
应该是这样的:
编辑:仍然不确定这是否能满足您的需求,但也许是一个很好的起点。如果没有通知我,我将删除。
CustomBinding cb = new CustomBinding()
{
SendTimeout = System.TimeSpan.FromMinutes(1),
ReceiveTimeout = System.TimeSpan.FromMinutes(1),
CloseTimeout = System.TimeSpan.FromMinutes(1),
OpenTimeout = System.TimeSpan.FromMinutes(1),
};
HttpsTransportBindingElement a = new HttpsTransportBindingElement();
a.MaxReceivedMessageSize = 10000000;
a.MaxBufferSize = 524288;
a.BypassProxyOnLocal = true;
a.AuthenticationScheme = AuthenticationSchemes.None;
SymmetricSecurityBindingElement b = SecurityBindingElement.CreateSspiNegotiationBindingElement(true);
TextMessageEncodingBindingElement c = new TextMessageEncodingBindingElement(MessageVersion.Soap11, System.Text.Encoding.UTF8);
SecurityBindingElement d = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
d.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
c.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxDepth = 32, MaxStringContentLength = 8192, MaxArrayLength = 16384, MaxBytesPerRead = 4096, MaxNameTableCharCount = 16384 };
cb.CreateBindingElements();
cb.Elements.Add(a);
cb.Elements.Add(b);
cb.Elements.Add(c);
cb.Elements.Add(d);