简体   繁体   English

XSD第一份合同--WCF Soap Web服务

[英]XSD first contract - WCF Soap Web service

I'm creating a Web Service using Visual Studio (2012). 我正在使用Visual Studio(2012)创建Web服务。 I don't want to bother with creating the WSDL manually, but I'd really like to be able to specify some of the types (or maybe all) using XSD, since it enables me to restrict certain elements (ex. require that an element is present). 我不想打扰手动创建WSDL,但我真的希望能够使用XSD指定一些类型(或者全部),因为它使我能够限制某些元素(例如,需要一个元素存在)。

How can I do this so that the resulting autogenerated WSDL use my XSD (with the same constraints)? 我怎么能这样做,以便生成的自动生成的WSDL使用我的XSD(具有相同的约束)?

The purpose is to make the interface (the WSDL) as accurate as possible (more accurate than an interface in C# can be). 目的是使接口(WSDL)尽可能准确(比C#中的接口更精确)。

In theory you could use WSCF.Blue to generate WSDL (and service) from and XSD. 理论上,您可以使用WSCF.Blue从XSD生成WSDL(和服务)。 In practice WCF runtime will not support all constraints that you can put inside XSD. 实际上,WCF运行时不支持可以放在XSD中的所有约束。 So your best bet is to use plain WCF data contracts and use the constraints that WCF allows you. 因此,最好的办法是使用普通的WCF数据协定并使用WCF允许的约束。 For example: 例如:

[DataMember(IsRequired = true)]
public int i;

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

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