wcfweb-configazureappfabricazure-appfabric

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


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="**********" />
        </clientCredentials>
      </transportClientEndpointBehavior>
      <ServiceRegistrySettings discoveryMode="Public"/>
    </behavior>
  </endpointBehaviors>
  ...
</behaviors>

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


Solution

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