wcfmessage-queuewebhttpbindingnetmsmqbinding

WCF inter-service messaging


I am building a system with 2 WCF Services. Both are IIS Hosted. At the moment they both reside in a single VS2010 website app, running on my local IIS7 (Windows 7) using the Derfault Website. I have enabled net.tcp on both.

Service1

Service2

Service 1 works as expected, however instead of placing the message on the configured Private Queue, our code is creating a new Queue under "Outgoing Queues" with the handle

DIRECT=TCP:127.0.0.1\private$\Service2/Service2.svc
note the forward slash

Of course Service2 never sees the message - this is the first time I have attempted this structure so I am not certain that Service2 misses the message because of its location, but based on what I have read it would seem so - I have not come across anything mentioning this Queue-creation behaviour.

Questions:

  1. Am I doing this correctly (is there something wrong in the structure, web.config or code)?

  2. When done properly in VS Debug, should Service1's

    proxy.ProcessForm(formMessage);

hit breakpoints in my Service2 code, or is there another way to hande Service2 debug (ala windows services for example)?

Service1 Web.Config

 <system.serviceModel>
    <bindings>
        <webHttpBinding>
            <binding name="webHttpFormBinding" crossDomainScriptAccessEnabled="true"/>
        </webHttpBinding>
        <netMsmqBinding>
            <binding name="MsmqFormMessageBindingClient" exactlyOnce="false" useActiveDirectory="false" >
                <security mode="None">
                    <message clientCredentialType="None"/>
                    <transport msmqAuthenticationMode="None" msmqProtectionLevel="None"  />
                </security>
            </binding>
        </netMsmqBinding>


    </bindings>
    <client>
        <endpoint
            name="HttpServiceWebEndpoint"
            address=""
            binding="webHttpBinding"
            bindingConfiguration="webHttpFormBinding"
            contract="Service1.HttpService.IHttpServiceWeb" />
        <endpoint name="MsmqFormMessageBindingClient"
            address="net.msmq://127.0.0.1/private/Service2/Service2.svc"
            binding="netMsmqBinding"
            contract="MyInfrastructure.IService2" />

    </client>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="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"/>
                <!--
                <serviceAuthenticationManager />
                -->
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

</system.serviceModel>

On Receipt of an HTTP Post Service1 executes the following:

StreamReader sr = new StreamReader(formData);
string str = sr.ReadToEnd();
var t = HttpUtility.ParseQueryString(str);
Hashtable nvc = new Hashtable();
foreach (string n in t)
{
    nvc.Add(n, (string)t[n]);
}
WcfFormMessage formMessage = new WcfFormMessage(nvc);

////create the Service binding
NetMsmqBinding msmq = new NetMsmqBinding("MsmqFormMessageBindingClient");
msmq.Security.Mode = (NetMsmqSecurityMode) MsmqAuthenticationMode.None;
EndpointAddress address = new EndpointAddress("net.msmq://127.0.0.1/private/Service2/Service2.svc");
ChannelFactory<IService2> factory = new ChannelFactory<IFormService>(msmq,address);
IService2 proxy = factory.CreateChannel();
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
    proxy.ProcessForm(formMessage);
   //do any 'sent to queue logging/updates here
}

Solution

  • I am ready to bet that your problem is related to 127.0.0.1 in your config. Type the machine name in there, even if it is local.