gpt4 book ai didi

c# - ProtocolException:传入的事务无法反序列化

转载 作者:太空宇宙 更新时间:2023-11-03 10:52:10 26 4
gpt4 key购买 nike

我有一个在不同环境中运行的简单 WCF 服务。今天,我尝试在我的 Windows 7 工作站上运行它,但在我的客户端(这是用于测试的简单控制台应用程序)上出现此错误:

System.ServiceModel.ProtocolException:无法反序列化传入事务。消息中的交易 header 格式不正确或格式无法识别。客户端和服务必须配置为使用相同的协议(protocol)和协议(protocol)版本。发生以下异常:与底层事务管理器的通信失败。

Server stack trace: 
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ConsoleApplication1.ServiceReference1.ILookupService.GetMaritalStatus()
at ConsoleApplication1.ServiceReference1.LookupServiceClient.GetMaritalStatus() in D:\\Temp\\ConsoleApplication1\\ConsoleApplication1\\Service References\\ServiceReference1\\Reference.cs:line 46975
at ConsoleApplication1.Program.Main(String[] args) in D:\\Temp\\ConsoleApplication1\\ConsoleApplication1\\Program.cs:line 24

如果我更改客户端上的端点以从任何其他环境调用相同的服务 - 它工作得很好。我确定我的工作站有问题,但无法弄清楚那是什么。 IIS 中的所有设置都与其他服务器上的相同。其他服务在工作站上运行良好。

服务契约(Contract)如下所示:

[ServiceContract]
public interface IMyService
{
[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
[FaultContract(typeof(ServiceFault))]
Result MethodName(Guid id);
}

实现:

[ServiceBehavior(Name = "MyService", InstanceContextMode = InstanceContextMode.PerCall)]
public class MyService : IMyService
{
public Result MethodName(Guid id)
{
...
}
}

我还没有创建这个服务,也不确定为什么我们可能需要 TransactionFlow 属性。这是导致问题的原因吗?我该如何解决?

Fiddler 显示了以下响应。没有任何帮助。

HTTP/1.1 500 Internal Server Error
Content-Length: 905
Content-Type: application/soap+xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 08 Jan 2014 18:45:33 GMT

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/transactions/fault</a:Action></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/transactions">a:TransactionHeaderMalformed</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="en-US">The incoming transaction cannot be deserialized. The transaction header in the message was either malformed or in an unrecognized format. The client and the service must be configured to use the same protocol and protocol version. The following exception occurred: Communication with the underlying transaction manager has failed.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>

最佳答案

Windows 更新似乎重置了 MSDTC 安全设置。我在 Windows 日志中发现了以下日志条目:

MSDTC encountered an error (HR=0x80000171) while attempting to establish a secure connection with system <HostName>.

所以我做了两件事:

1) 授予对 msdtc.log 的网络服务的完全访问权限:

icacls c:\windows\system32\msdtc\msdtc.log /grant "networkservice":F 

2) 更改了本地 DTC 的安全设置(控制面板 -> 管理工具 -> 组件服务 -> 我的电脑 -> 分布式事务协调器 -> 本地 DTC -> 属性)。我设置了以下内容(什么都没有设置):

Local DTC Properies -> Security

关于c# - ProtocolException:传入的事务无法反序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21002047/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com