それについてもっと読んで wshttpbinding を実装しようとした後、それは起こりません。何を試しても、次のエラーメッセージが表示され続けます(セキュリティモードがコメントアウトされています)。バインディング間の SOAP バージョンが異なるため、その理由は理解できます。
「(415) コンテンツ タイプ 'application/soap+xml; charset=utf-8' が予期されたタイプ 'text/xml; charset=utf-8' ではなかったため、メッセージを処理できません」
TransportWithMessageCredentials の詳細については、次のリンクを参照してください。
http://msdn.microsoft.com/en-us/library/ms789011.aspx
それでも動作させることができませんでした。
内部アプリにはbasicHttpBindingを問題なく使用でき、うまく機能します(トランザクションを含めない場合)が、WCFレイヤーのアプリケーションはまだトランザクションをサポートする必要があります(以下を参照)。そこから、basicHttpBindingがサポートされていないことがわかります、トランザクションフロー属性が含まれていないためです。
[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
セキュリティ モードを含めて以下を実行しようとすると、svc 構成エディターが起動せず、次のエラーがスローされます。 . 登録されているベース アドレス スキームは [http] です。"
ある種の SSL/https セキュリティが期待されていることは知っていますが、私の Web サイト (以下に示すように http) です。これは一般向けの Web サイトでは問題ありませんが、内部サイトについては、今のところ、トランザクションのサポートだけを行いたいと考えています。
wsHttpBinding のサーバー側の設定は次のとおりです。
<bindings>
<wsHttpBinding>
<binding name="WsHttpBinding_IYeagerTechWcfService" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="24.20:31:23.6470000" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transactionFlow="true">
<security mode="Transport" >
<transport clientCredentialType = "Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<?xml version="1.0"?>
<services>
<clear />
<service name="YeagerTechWcfService.YeagerTechWcfService">
<endpoint address="" binding="wsHttpBinding" contract="YeagerTechWcfService.IYeagerTechWcfService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://abc.com/yeagerte/YeagerTechWcfService.YeagerTechWcfService.svc" />
</baseAddresses>
</host>
</service>
</services>
クライアント側の設定は次のとおりです。
<?xml version="1.0"?>
<client>
<endpoint address="http://abc.com/yeagerte/YeagerTechWcfService.YeagerTechWcfService.svc"
binding="wsHttpBinding" contract="YeagerTechWcfService.IYeagerTechWcfService"
name="WsHttpBinding_IYeagerTechWcfService" />
</client>
誰かが次のことを教えてください:
basicHttpBinding またはその他の方法で WCF でトランザクションをサポートする別の方法はありますか?
もしそうなら、どうすれば実装できますか?
そうでない場合、どのような選択肢がありますか?
上記の質問については、私は答えを見つけたかもしれませんが、この問題についてより経験豊富な人に実行してもらいたいと思います.
(上記のように) WCF レイヤーでトランザクションを処理する代わりに、コントローラーでデータを WCF レイヤーに渡すときに、basicHttpBinding と次のコードを使用することを提案します。
// method here
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
db.EditCategory(cat);
// the above code would execute the EditCategory method below in the WCF layer and keep the transaction alive ts.Complete();
ts.Dispose();
}
return Json(new GridModel(db.GetCategories()));
// end method
WCF 層:
public void EditCategory(Category cat)
{
try
{
using (YeagerTechEntities DbContext = new YeagerTechEntities())
{
Category category = new Category();
category.CategoryID = cat.CategoryID;
category.Description = cat.Description;
// do another db update here or in another method...
DbContext.Entry(category).State = EntityState.Modified;
DbContext.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
SSL を使用する公開 Web サイトの場合、wsHttpBinding を適切に実装するにはどうすればよいですか?