从 WF TransactionScope 调用 WCF 时出现 ProtocolException

发布于 10-25 16:42 字数 1708 浏览 4 评论 0原文

我收到 SOAP 异常信息: “此消息的收件人无法理解命名空间“http://schemas.microsoft.com/ws/2006/02/tx/oletx”中的标头“OleTxTransaction”,导致消息无法处理。此错误通常表示该消息的发送者启用了接收者无法处理的通信协议,请确保客户端的绑定的配置与服务的绑定一致”

该方法定义为(默认情况下有。 TransactionFlowOption.NotAllowed):

[OperationContract]  
Foo GetFoo(int fooId);

同一服务中的其他方法定义如下:

[OperationContract]  
[TransactionFlowOption.Allowed]  
Foo GetFooTransactional(int fooId);

第一个方法在 WF TransactionScope 活动中调用时会引发异常,但从具有 TransactionScope 的常规控制台应用程序调用它时不会引发异常。

无论如何,第二个都有效。我可以只允许每种方法中的事务,但出于多种原因我不想这样做。

我正在使用命名管道绑定,允许客户端和服务器中的事务流。 服务器:

<netNamedPipeBinding>
    <binding transactionFlow="true" transactionProtocol="OleTransactions" transferMode="Buffered" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</netNamedPipeBinding>

客户端:

<netNamedPipeBinding>
    <binding name="DefaultNamedPipeConfig" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          transactionFlow="true" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
          maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="Transport">
             <transport protectionLevel="EncryptAndSign" />
         </security>
     </binding>
  </netNamedPipeBinding>

I'm getting a SOAP exception telling:
"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. "

The method is defined as (by default has TransactionFlowOption.NotAllowed):

[OperationContract]  
Foo GetFoo(int fooId);

Other method in the same service is defined like:

[OperationContract]  
[TransactionFlowOption.Allowed]  
Foo GetFooTransactional(int fooId);

The first one would throw the exception when called within a WF TransactionScope activity, but not when calling it from a regular console application with a TransactionScope.

The second works in any case. I could just allow transactions in every method, but for several reasons I don't want to do that.

I'm using named pipe bindings allowing transaction flow in clients and server.
Server:

<netNamedPipeBinding>
    <binding transactionFlow="true" transactionProtocol="OleTransactions" transferMode="Buffered" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</netNamedPipeBinding>

Client:

<netNamedPipeBinding>
    <binding name="DefaultNamedPipeConfig" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          transactionFlow="true" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
          maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="Transport">
             <transport protectionLevel="EncryptAndSign" />
         </security>
     </binding>
  </netNamedPipeBinding>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

装迷糊2024-11-01 16:42:00

我将服务器和客户端更新为.Net4.6.2,错误神奇地消失了。
服务器从 .Net 4.0 更新到 4.5 后,该错误出现在我的开发中。
我认为这大多数时候是 .Net 版本,但当然也可能是配置问题。在我必须更新服务器之前,我的软件运行良好,因为 DLL 已更新到 .Net 4.5。

祝你好运

I updated Server and Client to .Net4.6.2 and the Error magicaly disapeared.
The Error showed up in my Development after the Server was updated from .Net 4.0 to 4.5.
I think this most of the time a .Net Version but can of course be a config issues as well. My Software was working fine before i had to update the Server because a DLL was updated to .Net 4.5.

GoodLuck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文