WCF WSDL +的nillable属性 [英] WCF WSDL + Nillable Attributes
问题描述
我有一个平顶WSDL WCF服务和消费者在其另一端是告诉我的nillable =真的属性冲水它们。我试着设置在我的服务合同EmitDefaultValue =假的,但我没有发现任何行为改变。
诚然,我从来没有在这个挖成生成WSDL之前的水平,所以我有点失落。也许那里的代码下面贴,可能会解决我的问题位进行一个调整?如果我至少在正确的位置的时候,我会继续调查。
有一个简单的方法来消除从我的WSDL中的nillable =真属性,并且是将有意想不到的后果? !谢谢
公共类FlatWsdl:IWsdlExportExtension,IEndpointBehavior
{
公共无效ExportEndpoint(WsdlExporter出口国,WsdlEndpointConversionContext上下文)
{
的XmlSchemaSet schemaSet = exporter.GeneratedXmlSchemas;
的foreach(在exporter.GeneratedWsdlDocuments ServiceDescription WSDL)
{
名单,LT;的XmlSchema> importsList =新的List<&的XmlSchema GT;();
的foreach(在wsdl.Types.Schemas的XmlSchema模式)
{
AddImportedSchemas(架构,schemaSet,importsList);
}
wsdl.Types.Schemas.Clear();
的foreach(在importsList的XmlSchema模式)
{
RemoveXsdImports(架构);
wsdl.Types.Schemas.Add(架构);
}
}
}
...省略FlatWsdl.cs出于简洁的其余...
}
有没有直接简单的方式来实现这一目标。你将不得不使用 WsdlExporter 实施它自己。它是否会带来意想不到的后果取决于你的意图: - )
编辑:
有一个看 IWSDLExportExtension 的MSDN的例子。它可以让你做的正是你想要的。诚然,这是一个有点麻烦得到它的权利,但你正在寻找在正确的方向。
I have a WCF service with a Flattened WSDL, and the consumer at the other end is telling me the nillable="true" attributes are hosing them up. I tried setting EmitDefaultValue = false in my service contract, but I didn't notice any change in behavior.
Admittedly, I have never had to dig into WSDL generation at this level before so I'm a little lost. Perhaps there a tweak to be made in the bit of code posted below that may solve my problem? If I'm at least in the correct place, I'll keep investigating.
Is there a simple way to remove the nillable="true" attributes from my WSDL, and is that going to have unintended consequences? Thanks!
public class FlatWsdl : IWsdlExportExtension, IEndpointBehavior
{
public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
{
XmlSchemaSet schemaSet = exporter.GeneratedXmlSchemas;
foreach (ServiceDescription wsdl in exporter.GeneratedWsdlDocuments)
{
List<XmlSchema> importsList = new List<XmlSchema>();
foreach (XmlSchema schema in wsdl.Types.Schemas)
{
AddImportedSchemas(schema, schemaSet, importsList);
}
wsdl.Types.Schemas.Clear();
foreach (XmlSchema schema in importsList)
{
RemoveXsdImports(schema);
wsdl.Types.Schemas.Add(schema);
}
}
}
...omitted the rest of FlatWsdl.cs for brevity...
}
There's no direct simple way to achieve this. You'll have to use WsdlExporter to implement it yourself. Whether it will have unintended consequences depends on your intentions :-)
EDIT:
Have a look at the MSDN example of IWSDLExportExtension. It will allow you to do exactly what you want. Admittedly, it's a bit of a hassle to get it right, but you're looking in the right direction.
这篇关于WCF WSDL +的nillable属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!