我在互联网上搜索了多个资源,但我遇到过的是'Hello World'和'计算器',就像解释WCF消息合约的示例一样。我想知道在现实世界的企业应用程序中消息合同的实际用法,以及何时应该优先于数据合同。任何有关这方面的帮助将不胜感激。WCF消息合同实际示例
0
A
回答
0
例如,当一个Java客户端拥有一个不会改变的WSDL文件(技术原因)时,一个真实的活动场景就是例如。所以Java客户端有一个固定的WSDL文件。然后,Web服务(.net)必须提供此方法的确切名称,名称空间,操作和消息字符串。
示例Java客户端:
<operation name="remove">
<input wsam:Action="remove" message="tns:remove"/>
<output wsam:Action="removeResponse" message="tns:removeResponse"/>
</operation>
默认是自动生成的Web服务,这样的事情:
<wsdl:operation name="remove">
<wsdl:input message="tns:IService1_remove_InputMessage" wsaw:Action="http://tempuri.org/IService1/remove"/>
<wsdl:output message="tns:IService1_remove_OutputMessage" wsaw:Action="http://tempuri.org/IService1/removeResponse"
</wsdl:operation>
然后服务器和客户端得到一个不匹配的错误,因为客户端无法找到方法。为了解决这个问题,你必须改变action,replyAction和消息字符串。你必须改变第一和第二个:
<OperationContractAttribute(Action:="remove", name:="remove" ReplyAction:="removeResponse")> _
Function remove(key As string) As Boolean
新的WSDL文件(服务器):
<wsdl:operation name="remove">
<wsdl:input message="tns:IService1_remove_InputMessage" wsaw:Action="remove"/>
<wsdl:output message="tns:IService1_remove_OutputMessage" wsaw:Action="removeResponse"
</wsdl:operation>
现在你仍然得到同样的失配误差,因为消息字符串是不一样的。要解决这个问题,你需要消息合约。这使您可以操纵WSDL文件/ SOAP消息。 为此,该方法的语法在IService类中更改。
<OperationContractAttribute(Action:="remove", name:="remove" ReplyAction:="removeResponse")> _
Function remove(key As remove) As removeResponse
和消息合同确定的“类型”:
<MessageContract()> _
Public Class removeResponse
Private return1 As Boolean()
<DataMember(Name:="return")> _
Public Property returnP() As Boolean()
Get
Return Me.return1
End Get
Set(ByVal value As Boolean())
Me.return1 = value
End Set
End Property
End Class
<MessageContract()> _
Public Class remove
Private key1 As String()
<DataMember(Name:="key")> _
Public Property keyP() As String()
Get
Return Me.key1
End Get
Set(ByVal value As String())
Me.key1 = value
End Set
End Property
End Class
现在客户端和服务器之间的通信是确定。
WSDL(服务器):
<wsdl:operation name="remove">
<wsdl:input message="remove" wsaw:Action="remove"/>
<wsdl:output message="removeResponse" wsaw:Action="removeResponse"
</wsdl:operation>
相关问题
- 1. WCF消息安全性是否实际加密消息内容?
- 2. WCF消息合同和名称空间
- 3. Toast消息示例
- 4. Vim,实际使用示例
- 5. JMX或NetMX实际示例
- 6. WCF - CODEGEN:由于消息FileRequest具有标题而生成消息合同
- 7. HTML5消息多实例
- 8. User.history和实际消息发送
- 9. OpenPop.net获取实际消息文本
- 10. RabbitMQ如何实际存储消息?
- 11. 表格实施WCF合同
- 12. WinAPI消息队列示例
- 13. 谷歌云消息示例
- 14. WCF客户端访问与消息合同
- 15. WCF:添加服务参考创建消息合同
- 16. WCF:数据合同转换为消息协定
- 17. 如何控制通用WCF消息合同的名称
- 18. WCF自定义消息的实现
- 19. WCF消息证书实现细节
- 20. WCF中传输和消息可靠性的实际区别是什么?
- 21. 如何在WCF数据合同中包含类实例?
- 22. Boost :: MPL的实际用法示例?
- 23. “ref”使用的实际示例
- 24. 实际示例中的内存泄漏
- 25. Javascript关闭的实际用法/示例
- 26. 在WCF SOAP消息
- 27. WCF消息安全
- 28. WCF消息督察
- 29. 使用WCF消息
- 30. WCF消息记录
最好是设法实现它。 –
https://msdn.microsoft.com/en-us/library/ms730255.aspx是一个非常真实的世界示例 –
[DataContract vs Message Contract]的可能重复(http://stackoverflow.com/questions/4118654/datacontract -VS-消息合同) –