我在服务器端有以下绑定。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="customBinding1">
<security authenticationMode="UserNameForCertificate" requireDerivedKeys="true" messageProtectionOrder="SignBeforeEncryptAndEncryptSignature" requireSecurityContextCancellation="false" requireSignatureConfirmation="false">
<secureConversationBootstrap />
</security>
<httpTransport />
</binding>
</customBinding>
<wsFederationHttpBinding>
<binding name="FederatedClientProxy" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security>
<message issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1" negotiateServiceCredential="false">
<issuer address="http://localhost:16041/MySTS/SecurityTokenService" binding="customBinding" bindingConfiguration="customBinding1">
<identity>
<certificateReference x509FindType="FindBySubjectName" findValue="localhost" />
</identity>
</issuer>
</message>
</security>
</binding>
</wsFederationHttpBinding>
和服务部分如下
<service name="MyService.Hello">
<endpoint binding="wsFederationHttpBinding"
bindingConfiguration="FederatedClientProxy"
contract="MyService.IHello">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost/MyService.Hello" />
</baseAddresses>
</host>
</service>
当我为上面的配置添加服务引用时,它在 app.config 下面生成,其中不包括 customBinding1
<bindings>
<wsFederationHttpBinding>
<binding name="WSFederationHttpBinding_IHelloService"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<message algorithmSuite="Default" issuedKeyType="SymmetricKey"
issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
negotiateServiceCredential="false">
<issuer address="http://localhost:16041/MySTS/SecurityTokenService">
<identity>
<certificate encodedValue="AwAAA" />
</identity>
</issuer>
</message>
</security>
</binding>
</wsFederationHttpBinding>
</bindings>