我有一个在不同环境下运行的简单WCF服务。今天我尝试在我的Windows 7工作站上运行它并在我的客户端上获得此错误(这是用于测试的简单控制台应用程序):
System.ServiceModel.ProtocolException:无法反序列化传入的事务。邮件中的事务标头格式错误或格式无法识别。必须将客户端和服务配置为使用相同的协议和协议版本。发生以下异常:与基础事务管理器的通信失败。
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中的所有设置与其他服务器上的设置相同。其他服务在工作站上运行良好。
服务合同如下:
[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属性。这是否会导致问题。我该如何解决?
菲德勒表现出以下回应。什么都没有帮助。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>
答案 0 :(得分:2)
看起来Windows更新重置了MSDTC安全设置。我在Windows日志中找到了以下日志条目:
MSDTC encountered an error (HR=0x80000171) while attempting to establish a secure connection with system <HostName>.
所以我做了两件事:
1)授予完全访问msdtc.log的NetworkServices:
icacls c:\windows\system32\msdtc\msdtc.log /grant "networkservice":F
2)更改了本地DTC的安全设置(控制面板 - &gt;管理工具 - &gt;组件服务 - &gt;我的电脑 - &gt;分布式事务处理协调器 - &gt;本地DTC - &gt;属性)。我设置了以下内容(根本没有设置):