从 WF TransactionScope 调用 WCF 时出现 ProtocolException
我收到 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>
这似乎是一个错误4.0 版本
It seems to be a bug in the 4.0 release