2 つの WCF サービスを使用してシステムを構築しています。どちらも IIS でホストされています。現時点では、両方とも単一の VS2010 Web サイト アプリに存在し、Derfault Web サイトを使用してローカルの IIS7 (Windows 7) で実行されています。両方で net.tcp を有効にしました。
サービス1
- webHttpBinding を使用して HTTP 投稿を受け入れる
- シリアライズ可能な複合オブジェクトでデータをラップします
- netMsmqBinding を使用して複合オブジェクトを Service2 に送信します (期待しています)。
サービス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デバッグを処理する別の方法がありますか(たとえば、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
}