元素'behavior'具有无效的子'transportClientEndpointBehavior'也是basicHttpRelayBinding

时间:2011-03-01 15:44:28

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

在创建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的问题,我想它会包含在绑定中。

3 个答案:

答案 0 :(得分:0)

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

// 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();

答案 1 :(得分:0)

您安装了AppFabric SDK吗? ServiceRegistrySettings也应为serviceRegistrySettings

答案 2 :(得分:0)

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

答案来自“20487B-ENU-TrainerHandbook.pdf”,这是微软官方课程书。第278页