後enabling WCF tracing(與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' Blog,我們發現如下信息:
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 example中看到的那樣,使用MsmqIntegrationBinding需要一個接受所有消息的操作(Action = "*"
[或者的確,Action = ""
可能也會工作])。一旦我切換到msmqIntegrationBinding並切換我的合同(確保我仍然有新的ServiceKnownType
),一切都開始工作。