2011-03-01 19 views
3

创建WCF配置文件时,我可能会在Visual Studio中得到这个错误,因为VS编辑器不知道该扩展。我需要知道在哪里放置transportClientEndpointBehavior,有什么帮助?谢谢。元素“行为”具有无效子“transportClientEndpointBehavior”也basicHttpRelayBinding

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

我也有一个basicHttpRelayBinding的问题,我认为它被包含在绑定下。

回答

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

Visual Studio Intellisense使用内置模式来执行验证。因此, 不会识别transportClientEndpointBehavior行为扩展,并会显示警告。 忽视此警告。

答案是从“20487B-ENU-TrainerHandbook.pdf”,这是微软官方教材。 Page 278

+0

您不能忽视这一点。我遇到同样的问题,因此无法启动服务。因为这是行为的一个元素,所以行为本身是无效的。因此,由于枚举约束,使用该行为的端点反过来是无效的。 – 2016-05-19 12:59:58

+0

我的答案来自微软正式课本“20487B-ENU-TrainerHandbook.pdf”。页面278 – ssinotna 2016-06-01 15:36:31

相关问题