2014-09-10 74 views
0

我有1個服務和多個端點,如下所示。我想有一個普遍的行爲,並用另一個行爲覆蓋我的wshttpbinding,但是當我嘗試接收錯誤時告訴我WCF-1服務,多個端點和多個行爲?

解析器錯誤消息:沒有名爲'CredentialValidator'的終結點行爲。

我做錯了什麼?

<services> 
    <service name="myservice.Service.myserviceService" behaviorConfiguration="myserviceBehaviour"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="https://localhost:44300/myService.svc"/> 
     <!--<add baseAddress="http://localhost:54941/myService.svc"/>--> 
     <!--<add baseAddress="http://myservicewcf.myurl-staging.com/myService.svc"/>--> 
     <add baseAddress="https://myservice.myurl-staging.com/myService.svc"/> 
     <add baseAddress="https://myservice.production.com/myService.svc"/> 
     <!--<add baseAddress="https://myservicetest.myurl-staging.com/myService.svc"/>--> 
     </baseAddresses> 
    </host> 
    <endpoint name="myserviceSoap12Endpoint" address="soap12" binding="customBinding" bindingConfiguration="soap12selfBinding" contract="myservice.Service.ImyserviceService" behaviorConfiguration="CredentialValidator" /> 
    <endpoint name="myserviceWSHttpEndpoint" address="ws" binding="wsHttpBinding" bindingConfiguration="myserviceWSHttpBinding" contract="myservice.Service.ImyserviceService"/> 
    <endpoint name="myserviceBasicHttpEndpoint" address="" binding="basicHttpBinding" bindingConfiguration="myserviceBasicHttpBinding" contract="myservice.Service.ImyserviceService"/> 
    <!--<endpoint name="myserviceBasicHttpEndpoint2" address="" binding="basicHttpBinding" bindingConfiguration="myserviceBasicHttpBinding" contract="myservice.Service.ImyserviceService2"/>--> 
    <endpoint name="myserviceMexEndpointHttps" address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name ="CredentialValidator"> 
     <serviceMetadata httpsGetEnabled="true"/> 
     <serviceDebug 
     includeExceptionDetailInFaults="true"/> 
     <serviceCredentials> 
     <userNameAuthentication userNamePasswordValidationMode="Custom" 
           customUserNamePasswordValidatorType="myservice.Service.CustomUserNameValidator, myservice"/>   
     </serviceCredentials> 
    </behavior> 
    <behavior name="myserviceBehaviour"> 
     <useRequestHeadersForMetadataAddress/> 
     <serviceMetadata httpsGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

回答

1

嘗試把你的CredentialValidator行爲<endpointBehaviors>標籤,而不是<serviceBehaviors>

因爲例外消息明確指出沒有任何endpointBehavior這個名稱。所以給它一個!像這樣:

<behaviors> 
    **<endpointBehaviors>** 
    <behavior name ="CredentialValidator"> 
     <serviceMetadata httpsGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    **</endpointBehaviors>** 

    <serviceBehaviors> 
    <behavior name="myserviceBehaviour"> 
     <useRequestHeadersForMetadataAddress/> 
     <serviceMetadata httpsGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
+0

是不是適合客戶端?我正在嘗試這個服務方面。基本上我想保護我的自定義綁定憑證,而basichttp不具有此行爲。我通過在行爲中添加憑據來編輯我的代碼。 EndpointBehaviour不像預期的那樣擁有serviceCredentials。 – batmaci 2014-09-10 13:37:46

+0

btw錯誤消息does not告訴我,「endpointbehaviour」,但「端點行爲」,我不知道它是否有任何區別作爲條款 – batmaci 2014-09-10 13:39:02