绑定不是通过VS添加服务引用生成的

时间:2012-04-19 10:48:29

标签: c# wcf service configuration

我在服务器端有以下绑定。

 <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>

1 个答案:

答案 0 :(得分:0)

未生成,因为您的服务中没有端点正在使用绑定。

顺便说一下。您的自定义绑定还需要一些消息编码元素 - 最可能textMessageEncoding messageVersion设置为您的方案的适当SOAP版本。