开发者

The element 'behavior' has invalid child 'transportClientEndpointBehavior' also basicHttpRelayBinding

开发者 https://www.devze.com 2023-02-13 23:29 出处:网络
I might get this error in Visual Studio when creating the WCF config file, since the VS editor doesn\'t know about that extension. I need to know where to place transportClientEndpointBehavior, any he

I might get this error in Visual Studio when creating the WCF config file, since the VS editor doesn't know about that extension. I need to know where to place transportClientEndpointBehavior, any help ? thanks.

 <behaviors>
  <endpointBehaviors>
    <behavior name="sharedSecretClientCredentials">
      <transportClientEndpointBehavior credentialType="SharedSecret">
        <clientCredentials>
          <sharedSecret issuerName="***********" issuerSecret="**********" />
        </clientCredenti开发者_运维技巧als>
      </transportClientEndpointBehavior>
      <ServiceRegistrySettings discoveryMode="Public"/>
    </behavior>
  </endpointBehaviors>
  ...
</behaviors>

I also have a problem with basicHttpRelayBinding which i suppose to be included under bindings.


There is a sample in the Windows Azure Platform Training Kit that does this programmaticly. Here is the sample 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();


Have you installed the AppFabric SDK? ServiceRegistrySettings should also be serviceRegistrySettings.


Visual Studio Intellisense uses built-in schemas to perform validations. Therefore, it will not recognize the transportClientEndpointBehavior behavior extension, and will display a warning. Disregard this warning.

The answer is from "20487B-ENU-TrainerHandbook.pdf" which is Microsoft official course book. Page 278

0

精彩评论

暂无评论...
验证码 换一张
取 消