简体   繁体   English

支持XSD限制的WCF服务?

[英]WCF Service that supports XSD restrictions?

I've been struggling the past day trying to find a way to generate a WCF Service that actually maintains the restrictions that are defined in the originating XSDs. 在过去的一天里,我一直在努力寻找一种生成WCF服务的方法,该方法实际上维护了原始XSD中定义的限制。 The basic problem is that if I build a contract first service using an XSD that includes restrictions (for example patterns) the restrictions are removed from the WSDL/XSDs that are output when deploying the service. 基本问题是,如果我使用包含限制(例如模式)的XSD构建合同优先服务,则该限制将从部署服务时输出的WSDL / XSD中删除。

Here is someone else complaining about the same problem: http://geekswithblogs.net/wojan/archive/2010/12/10/143086.aspx 这是其他人抱怨同样的问题: http : //geekswithblogs.net/wojan/archive/2010/12/10/143086.aspx

I'm left with what I think are 2 options: 我剩下2种选择:

  • Can I replace the service generated WSDL/XSD on the web server (IIS or IIS Express) 我可以替换Web服务器(IIS或IIS Express)上的服务生成的WSDL / XSD吗?
  • Can I replace the default XML Serializer with another 3rd party serializer that does properly support XSD restrictions. 我可以用另一个正确支持XSD限制的第三方串行器替换默认的XML串行器。

Thoughts? 有什么想法吗?

You can replace the built-in WCF generated WSDL by doing something along the lines of what this very good blog post did . 您可以按照此非常好的博客文章的内容进行操作,以替换内置的WCF生成的WSDL。 That post shows how override the default WCF behavior of generating included references for the XSDs instead creating a single "flat" WSDL document. 该文章显示了如何覆盖默认的WCF行为,即为XSD生成包含的引用,而不是创建单个“平面” WSDL文档。

The problem I see is that you need a way to communicate the additional XSD restrictions for this process. 我看到的问题是,您需要一种方法来传达此过程的其他XSD限制。 It's good you aware that you also need to replace the built-in XML serializer to get strict XSD compliance in the soap deserialization process because that is the only way to achieve what you want. 很高兴您知道,您还需要替换内置XML序列化程序以在肥皂反序列化过程中获得严格的XSD遵从性,因为这是实现所需目标的唯一方法。 Given all the deep customization's you'd need to make to WCF, you may actually want to consider rolling your own custom SOAP stack. 考虑到您需要对WCF进行的所有深度定制,您实际上可能要考虑滚动自己的定制SOAP堆栈。 I'm not aware of any other .NET framework (Microsoft or 3rd party) that does this. 我不知道执行此操作的任何其他.NET框架(Microsoft或3rd party)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM