This sample demonstrates how to expose and consume a service endpoint using the NetOnewayRelayBinding binding.

Prerequisites

If you haven't already done so, please read the release notes document that explains how to sign up for a Windows Azure account and how to configure your environment.

Service

The service and client both use the following simple contract:

C# 
[ServiceContract(Name = "IOnewayContract", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
    public interface IOnewayContract
    {
        [OperationContract(IsOneWay = true)]
        void Send(int count);
    } 

The endpoints for this service are defined in the application configuration file, as follows:

Xml 
<service name="Microsoft.ServiceBus.Samples.OnewayService">
    <endpoint address="" behaviorConfiguration="sharedSecretClientCredentials"
       binding="netOnewayRelayBinding" bindingConfiguration="default"
       name="RelayEndpoint" contract="Microsoft.ServiceBus.Samples.IOnewayContract" />
</service>

The client is configured with the following endpoint:

Xml 
<client>
    <!-- Application Endpoint -->
    <endpoint name="RelayEndpoint"
        contract="Microsoft.ServiceBus.Samples.IOnewayContract"
        binding="netOnewayRelayBinding"
        bindingConfiguration="default"
        behaviorConfiguration="sharedSecretClientCredentials" 
        address="http://AddressToBeReplacedInCode/" />
</client>

The address is a placeholder that will be replaced in the application.

Building and Running the Sample

Before building the solution, perform the following steps to update the App.config files

  1. Open the App.config file in the \Service folder, replace "ISSUER_NAME" with "owner" and "ISSUER_SECRET" with the actual issuer secret.

  2. Open the App.config file in the \Client folder, replace "ISSUER_NAME" with "owner" and "ISSUER_SECRET" with the actual issuer secret.

After building the solution, do the following to run the application:

  1. From a command prompt, run the service application from Service\bin\Debug\Service.exe.

  2. When prompted, enter the service namespace. At this point, the service should be running and prints the following text "Press [Enter] to exit".

  3. From another command prompt, run the client application from Client\bin\Debug\Client.exe.

  4. You will be prompted for the service namespace with which to connect (the service namespace specified in step 2).  At this point, the client should start sending messages to the service. Note that by default, the client sends a total of 25 messages.

Did you find this information useful?  Please send your suggestions and comments about the documentation.