【问题标题】:The element 'behavior' has invalid child 'transportClientEndpointBehavior' also basicHttpRelayBinding元素“行为”具有无效的子“transportClientEndpointBehavior”以及basicHttpRelayBinding
【发布时间】:2011-03-01 15:44:28
【问题描述】:

创建 WCF 配置文件时,我可能会在 Visual Studio 中收到此错误,因为 VS 编辑器不知道该扩展名。我需要知道将 transportClientEndpointBehavior 放在哪里,有什么帮助吗?谢谢。

 <behaviors>
  <endpointBehaviors>
    <behavior name="sharedSecretClientCredentials">
      <transportClientEndpointBehavior credentialType="SharedSecret">
        <clientCredentials>
          <sharedSecret issuerName="***********" issuerSecret="**********" />
        </clientCredentials>
      </transportClientEndpointBehavior>
      <ServiceRegistrySettings discoveryMode="Public"/>
    </behavior>
  </endpointBehaviors>
  ...
</behaviors>

basicHttpRelayBinding 也有问题,我认为它应该包含在绑定中。

【问题讨论】:

    标签: wcf web-config azure appfabric azure-appfabric


    【解决方案1】:

    Windows Azure 平台培训工具包中有一个以编程方式执行此操作的示例。这是示例代码段...

    // create the service URI based on the service namespace
            Uri address = ServiceBusEnvironment.CreateServiceUri("sb",
                          serviceNamespaceDomain, "EchoService");
    
            // create the credential object for the endpoint
            TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
            sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.SharedSecret;
            sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName = issuerName;
            sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret = issuerSecret;
    
            // create the service host reading the configuration
            ServiceHost host = new ServiceHost(typeof(EchoService), address);
    
            // create the ServiceRegistrySettings behavior for the endpoint
            IEndpointBehavior serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public);
    
            // add the Service Bus credentials to all endpoints specified in configuration
            foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
            {
                endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
            }
    
            // open the service
            host.Open();
    

    【讨论】:

      【解决方案2】:

      您是否安装了AppFabric SDKServiceRegistrySettings 也应该是 serviceRegistrySettings

      【讨论】:

        【解决方案3】:

        Visual Studio Intellisense 使用内置架构来执行验证。因此,它不会 识别 transportClientEndpointBehavior 行为扩展,并将显示警告。 忽略此警告。

        答案来自微软官方教材“20487B-ENU-TrainerHandbook.pdf”。第 278 页

        【讨论】:

        • 你不能忽视这一点。我遇到了同样的问题,因此服务无法启动。因为这是行为的一个元素,所以行为本身是无效的。因此,由于枚举约束,使用该行为的端点又是无效的。
        • 我的答案来自微软官方课程书“20487B-ENU-TrainerHandbook.pdf”。第 278 页
        猜你喜欢
        • 1970-01-01
        • 2016-10-23
        • 2021-03-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-28
        • 2012-05-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多