У меня есть сервис WCF, доступный по Интернету, который использует wsHttpBinding с удостоверениями клиента режима безопасности и имени пользователя сообщения.
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding" messageEncoding="Mtom" maxReceivedMessageSize="104857600">
<readerQuotas maxArrayLength="104857600"/>
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Я выяснил, что требуется слишком много времени для передачи моих данных от клиента к серверу. Я считал, что могу использовать customBinding и binaryEncoding режим для моего сервиса.
Как этот:
<bindings>
<customBindings>
<binding name="NetHttpBinding">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBindings>
<bindings>
Но вот не упоминание о режиме безопасности сообщения и клиентском учетном типе...
Как я мог использовать пользовательскую привязку с binaryEncoding и сохранить режим безопасности сообщения с удостоверениями клиента имени пользователя?
Установите secureConversationBootstrap на UserNameForSslNegotiated. Попробуйте что-то похожее на привязку ниже.
<bindings>
<customBinding>
<binding name="wss-username-binary">
<transactionFlow/>
<security
authenticationMode="SecureConversation"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap
authenticationMode="UserNameForSslNegotiated"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
</security>
<binaryMessageEncoding />
<httpTransport/>
</binding>
</customBinding>
</bindings>
Попробуйте это, это может помочь вам больше---- он имеет пользовательскую привязку, пользовательскую безопасность и сертификат.
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="CommonBinding" maxReceivedMessageSize ="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Custom.Security.CustomUserNameValidator, Custom.Security" />
<clientCertificate>
<authentication certificateValidationMode= "PeerOrChainTrust" />
</clientCertificate>
<serviceCertificate findValue="CertName" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="True"/>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="Custom.Security.AuthorizationPolicy, Custom.Security" />
</authorizationPolicies>
</serviceAuthorization>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>