使用 WCF 中的架构进行消息验证
我想要的是用很少的属性(例如最小、最大、字符串长度等)来装饰我的数据契约,并获取为我的 SOAP(非 .net)客户端生成的 XML 模式。经过对互联网的一些研究,我发现了以下文章:
这似乎是相当手动的大部头书。我正在寻找一些更体面的解决方案和开箱即用的功能。 WCF 提供了如此多的功能,如果它忽略了 SOAP 标准验证的整个概念,我会感到惊讶。
对此的任何帮助将不胜感激。
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:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DataContract
对象的 XML 模式可以在服务的 WSDL 中找到。由于多种原因,WCF 不会根据这些架构显式验证肥皂消息。首先,反序列化soap 消息的过程实际上是根据数据类上定义的DataContract
或XML 序列化执行验证。其次,如果每条肥皂消息都根据 XML 模式进行验证,那么性能肯定会受到影响。最后,WCF 通过IExtensibleDataObject
可选接口功能支持 SOAP 消息版本控制,以实现向前和向后兼容性。为此,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 theDataContract
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 theIExtensibleDataObject
optional interface capability. To do this, XML schema validation would most likely be too strict.