简体   繁体   English

如何说服WCF数据合同序列化程序WSDL被doc / lit / wrapped

[英]How to convince WCF Data Contract Serializer that a WSDL is doc/lit/wrapped

I've tried to follow the guidance at http://blogs.msdn.com/b/donsmith/archive/2006/10/06/handcrafting-wcf_2d00_friendly-wsdls.aspx for creating a WSDL that the WCF svcutil will believe is in the document/literal wrapped format. 我试图遵循http://blogs.msdn.com/b/donsmith/archive/2006/10/06/handcrafting-wcf_2d00_friendly-wsdls.aspx上的指导来创建WCF svcutil将相信的WSDL。文档/文字包装格式。 In so doing, svcutil should generate a service interface and proxy code in C# that uses the data contract serializer, and OperationContractAttributes on the wrapper operations. 这样,svcutil应该在C#中生成一个服务接口和代理代码,该代码使用数据协定序列化程序以及包装程序操作上的OperationContractAttributes。 Instead I get a weird double-wrapping with BlahResponse1 classes nested in BlahResponse clases, and svcutil tells me the WSDL is not wrapped and that it will create MessageContracts rather than OperationContracts. 取而代之的是,我使用嵌套在BlahResponse中的BlahResponse1类得到了一个奇怪的双重包装,并且svcutil告诉我WSDL没有包装,它将创建MessageContracts而不是OperationContracts。

For the sake of code-readability by my service consumers, I want to get rid of the BlahResponse1 class, and convince svcutil that the WSDL is wrapped. 为了使服务使用者能够读取代码,我想摆脱BlahResponse1类,并让svcutil相信WSDL已包装。 How does one do that? 怎么做到的? Maybe also, how does one not do that? 也许还,一个人如何这样做呢?

I've seen suggestions to set nillable="true" on some but not all elements in the schema which will become the data contract. 我已经看到建议在架构中的某些但不是全部元素上设置nillable =“ true”,这些元素将成为数据协定。 Which should be nillable and why? 哪个应该是可修剪的,为什么? Would there ever need to be elements that are not nillable, where setting nillable="true" is bad? 在设置nillable =“ true”不好的情况下,是否将需要存在不可设置的元素?

I tried dividing the schema into two namespaces as the above link suggests, but that didn't seem to work (or was masked by another problem). 我尝试按照上述链接的建议将模式分为两个名称空间,但这似乎不起作用(或被另一个问题掩盖了)。 Is there anything about schema namespaces, imports versus includes, and orders of declaration that are important? 关于架构名称空间,导入与包含以及声明顺序有什么重要的东西吗?

I would include the schema/WSDLs, but the are kind of proprietary. 我将包括模式/ WSDL,但它们是专有的。 Also, very large and spread across many files. 同样,它很大,并且分布在许多文件中。

XMLSpy creates message parts with a default name of "parameter." XMLSpy创建消息部分,其默认名称为“参数”。 That is almost what .NET svcutil.exe needs to autogenerate data contracts and operation contracts. .NET svcutil.exe几乎是自动生成数据协定和操作协定所需要的。 Svcutil.exe needs all message parts to be named "parameters" (notice the added 's' at the end). Svcutil.exe需要将所有消息部分命名为“参数”(请注意在末尾添加了“ s”)。

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

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