2017-04-12 5 views
0

私はwcfサービスでenbleトランザクションフローを試しています。WCFサービスでのTransactionScope例外

私は次のエラーを取得するしかし:

The header 'OleTxTransaction' from the namespace 'http://schemas.microsoft.com/ws/2006/02/tx/oletx' was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process. Please ensure that the configuration of the client's binding is consistent with the service's binding. 

これは私が実行しようとしているコードのコードスニペットです:

var transactionOptions = new TransactionOptions 
           { 
            IsolationLevel = IsolationLevel.ReadCommitted 
           }; 

using (var transaction = new TransactionScope(TransactionScopeOption.Required, transactionOptions)) 
     { 
      try 
      { 
       var company = CreateCompanyDto(settings); 

       if (settings.Institution.CompletedSetup) 
       { 
        _ezFinanceCompanyServiceLibrary.UpdateCompany(company); // This is the wcf call. 
       } 
       else 
       { 
        _ezFinanceCompanyServiceLibrary.CreateCompany(company); // This is the wcf call. 
        CreateDefaultInventroyItems(company.EntityGuid); 
       } 

       _db.SaveChanges(); 
       transaction.Complete(); 

       return true; 
      } 
      catch (Exception exception) 
      { 
       _log.Error(exception.Message); 
       return false; 
      } 
     } 

これは、web.configファイルで私のバインディングのオプションですウェブAPIの

<bindings> 
    <netTcpBinding> 
    <binding name="netTcpBindingbehavior" transactionFlow="true" portSharingEnabled="true" /> 
    </netTcpBinding> 
    <netMsmqBinding> 
    <binding name="netMsmqBinding"> 
     <security mode="None" /> 
    </binding> 
    </netMsmqBinding> 
</bindings> 

wcfで私のサービスインターフェイスにオペレーションコントラクトを持っています

[OperationContract] 
[TransactionFlow(TransactionFlowOption.Allowed)] 
int CreateCompany(CompanyDto newCompany); 
[OperationContract] 
[TransactionFlow(TransactionFlowOption.Allowed)] 
int UpdateCompany(CompanyDto Company); 

私は、私の公開されたメソッドで、次の属性私は、ネットワークDTCアクセスを有効にしているWCFサービス

<bindings> 
    <netTcpBinding> 
    <binding name="netTcpBinding" transactionFlow="true" portSharingEnabled="true" /> 
    </netTcpBinding> 
</bindings> 

内のApp.configに

[OperationBehavior(TransactionScopeRequired = true)] 

マイバインディングのオプションを持っています私はInbounndとOutboundを許可し、認証は必要ありません。サービスとWeb APIの両方で

transactionProtocol="OleTransactions" 

: 私はXAトランザクションを有効にし、SNA LU 6.2取引

てきた私は、私のバインディングに次の属性を追加しようとしています。

問題の原因を特定できないようです。

答えて

0

はすでに[OperationContract]削除するすべての[OperationContract]の属性を持っていたし、WCFによって公開されたメソッドは、問題を解決した上でのみ、それらを置くWCFメソッドによって呼び出されたメソッドの上に置かれ[OperationContract]属性があったことが判明します。

関連する問題