我正在构建一个包含2个WCF服务的系统。两者都是IIS托管。目前,它们都位于一个VS2010网站应用程序中,使用Derfault网站在我的本地IIS7(Windows 7)上运行。我已经在两者上启用了net.tcp。
Service1
服务2
服务1按预期工作,但是我们的代码不是将消息放在已配置的专用队列上,而是使用句柄在“传出队列”下创建一个新队列
DIRECT=TCP:127.0.0.1\private$\Service2/Service2.svc
note the forward slash
当然Service2永远不会看到这条消息 - 这是我第一次尝试这种结构,所以我不确定Service2因为它的位置而错过了该消息,但根据我所看到的情况,它似乎是这样 - 我有没有提到任何提及这种队列创造行为的事情。
问题:
我是否正确地执行此操作(结构,web.config或代码中是否有错误?)
在VS Debug中正确完成后,应该是Service1的
proxy.ProcessForm(formMessage);
在我的Service2代码中点击断点,还是有另一种方法来处理Service2调试(例如ala windows服务)?
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>
收到HTTP Post Service1后,执行以下操作:
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
}
答案 0 :(得分:3)
我准备打赌您的问题与配置中的127.0.0.1有关。在那里输入机器名称,即使它是本地的。