2013-01-14 103 views
0

我正在构建一个包含2个WCF服务的系统。这两个都是IIS托管的。目前,他们都在一个VS2010网站应用程序中,使用Derfault网站在我的本地IIS7(Windows 7)上运行。我已经启用net.tcp。WCF服务间消息传递

服务1

  • 接受使用的WebHttpBinding
  • 包装在一个可序列化的复合对象的数据
  • 发送复合对象到服务2(我们希望)使用netMsmqBinding

服务2

HTTP帖子
  • 接收所述消息,并做一些事情与它

服务1部作品如预期,但而不是将邮件上所配置的专用队列,我们​​的代码是创建“传出队列”下一个新的队列与手柄

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

当然,Service2从来没有看到消息 - 这是我第一次尝试这种结构,所以我不确定Service2是否由于它的位置而错过了消息,但基于我读过的东西看起来如此 - 我还没有发现任何提到这种队列创建行为的东西。

问题:

  1. 上午我正确地做这个(有什么不对劲的结构,web.config文件或代码)?

  2. 当VS调试,应该服务1的

    proxy.ProcessForm(formMessage)得当;

命中我的Service2代码中的断点,还是有另一种方法来处理Service2调试(例如ala windows服务)?

服务1 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> 

在一个HTTP POST服务1的收据执行:

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 
} 

回答

3

我愿意打赌,你的问题是,在你的配置关系到127.0.0.1 。在那里键入机器名称,即使它是本地的。