2014-09-10 75 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