启用 WCF 跟踪(使用)后switchValue="All"
,我可以看到我收到以下异常:
An error occurred while deserializing an MSMQ message's XML body. The message cannot be received. Ensure that the service contract is decorated with appropriate [ServiceKnownType] attributes or the TargetSerializationTypes property is set on the MsmqIntegrationBindingElement.
在为我的每个类型找到要添加的正确合同后ServiceKnownType
,我遇到了进一步的异常:
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
从Simon Evans 的博客中,我们发现了以下信息:
MsmqIntegrationBinding requires contracts that are designed only for its use. Unless additional behaviors are applied to the dispatcher, the service contract can contain only one service operation.
基本上,正如我们在MSDN 示例中看到的那样,使用 MsmqIntegrationBinding 需要一个接受所有消息的操作(Action = "*"
[或者,实际上,Action = ""
可能也可以工作])。一旦我切换到 msmqIntegrationBinding 并切换了我的合同(确保我还有ServiceKnownType
新合同),一切都开始工作了。