问题描述
我想要的是用很少的属性(例如min,max,字符串长度等)修饰我的数据协定,并获取为我的SOAP(非.net)客户端生成的XML模式.在对互联网进行一些研究之后,我发现了以下文章:
What I want is to decorate my data contracts with few attributes (e.g. min,max, string length etc.) and get the XML schema generated for my SOAP (non .net) clients. After some research on internet, I have come across the following article:
这对我来说似乎很手工.我正在寻求一些更合理的解决方案和即用型功能.有了WCF这么多的功能,如果它错过了SOAP标准验证的整个概念,我会感到惊讶.
This seems to be pretty manual to me. I am after some more decent solution and out of the box functionality. With WCF offering so much, I will be surprised if it has missed this whole concept of SOAP standard validation.
在此方面的任何帮助将不胜感激.
Any help on this will be much appreciated.
推荐答案
在服务的WSDL中可以找到DataContract
对象的XML模式.由于多种原因,WCF并未针对这些模式显式验证肥皂消息.首先,反序列化肥皂消息的过程实际上是根据数据类上定义的DataContract
或XML序列化执行验证的.接下来,如果每个肥皂消息都已针对XML模式进行了验证,那么性能肯定会受到影响.最后,WCF通过IExtensibleDataObject
可选接口功能支持肥皂消息版本控制,以实现向前和向后兼容性.为此,XML模式验证很可能过于严格.
The XML schemas for the DataContract
objects are found in the WSDL for the service. WCF does not explicitly validate soap messages against these schemas for a number of reasons. First, the process of deserializing soap messages, in effect, performs validation based on the DataContract
or XML serialization defined on the data classes. Next, there is a definite performance hit if every soap message was being validated against the XML schemas. Lastly, WCF supports soap message versioning for both forward and backward compatibility through the IExtensibleDataObject
optional interface capability. To do this, XML schema validation would most likely be too strict.
这篇关于使用WCF中的架构进行消息验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!