Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

WCF service unable to listen to Service Bus Subscription endpoint

$
0
0

Hi,

I have a WCF Service as follows:

public class Service1 : IService1
    {
        public void GetMessage(SBMessage value)
        {
            File.Create(@"E:\scratch\test100.txt");
        }


    }

    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract(IsOneWay = true)]
        void GetMessage(SBMessage value);

        // TODO: Add your service operations here
    }

    [DataContract]
    public class SBMessage
    {
        private string _stringValue;

        [DataMember]
        public string StringValue
        {
            get { return _stringValue; }
            set { _stringValue = value; }
        }
    }

The Web.config is as follows:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="securityBehavior">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedSecret issuerName="owner" issuerSecret="........" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
          <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>   
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <extensions>
      <!-- In this extension section we are introducing all known service bus extensions. User can remove the ones they don't need. -->
      <behaviorExtensions>
        <add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </behaviorExtensions>

      <bindingElementExtensions>
        <add name="netMessagingTransport" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingElementExtensions>

      <bindingExtensions>
        <add name="netMessagingBinding" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>

    </extensions>
    <bindings>
      <netMessagingBinding>
        <binding name="messagingBinding" closeTimeout="00:03:00" openTimeout="00:03:00"
             receiveTimeout="00:03:00" sendTimeout="00:03:00" sessionIdleTimeout="00:01:00" prefetchCount="-1">
          <transportSettings batchFlushInterval="00:00:01" />
        </binding>
      </netMessagingBinding>
    </bindings>
    <services>
      <service name="WcfService2.Service1">
        <endpoint name="Service1" listenUriMode="Explicit"
listenUri="sb://azuremania.servicebus.windows.net/MalwareDeterminationTopic/Subscriptions/ReceiveAll2"
                  address="sb://azuremania.servicebus.windows.net/MalwareDeterminationTopic"
                  binding="netMessagingBinding"
                  bindingConfiguration="messagingBinding"
                  contract="WcfService2.IService1"
                  behaviorConfiguration="securityBehavior" />
      </service>
    </services>


  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

I am deploying the WCF service in IIS with AppFabric 1.1 installed to enable service auto start in IIS.

I am using the following code to submit message to the topic

            string connectionString =
                ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"].ToString();
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            if (!namespaceManager.TopicExists("MalwareDeterminationTopic"))
            {
                namespaceManager.CreateTopic("MalwareDeterminationTopic");
            }

            //namespaceManager.DeleteSubscription("MalwareDeterminationTopic", "ReceiveAll2");

            if (!namespaceManager.SubscriptionExists("MalwareDeterminationTopic", "ReceiveAll2"))
            {
                namespaceManager.CreateSubscription("MalwareDeterminationTopic", "ReceiveAll2");
            }

            TopicClient client = TopicClient.CreateFromConnectionString(connectionString, "MalwareDeterminationTopic");
            BrokeredMessage message = new BrokeredMessage(new SBMessage {StringValue = "val1"});
            //BrokeredMessage testMessage = new BrokeredMessage("hello");
            message.Properties["contextId"] = "guid1";
            client.Send(message);

However, the WCF service does not get executed after sending the message to the topic (as shown below). Any idea what might be going wrong ?


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>