繁体   English   中英

WCF DataContract GetCustomDataToExport

[英]WCF DataContract GetCustomDataToExport

我正在尝试获取引用我的WCF WSDL的客户端的默认行为,以便在导入的DataContracts上将IsReference设置为true。 看起来我应该能够使用带有GetCustomDataToExport的IDataContractSurrogate来实现这一点......这具体意味着将以下内容添加到与WSDL关联的xsd中生成的ComplexType:

  <xs:attribute ref="ser:Id" /> 
  <xs:attribute ref="ser:Ref" /> 

当然,我无法从MS中找到有关如何使用此方法的可用文档。 MSDN页面说它应该返回一个对象......但是根本不指示这应该是什么类型的对象....多么无用......

在我为此反思之前,有没有人知道如何使用这种方法?

谢谢。

结束使用IWsdlExportExtension,如下所示:

   public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
    {
        foreach (var complexType in exporter.GeneratedXmlSchemas.Schemas().OfType<XmlSchema>().SelectMany(s => s.SchemaTypes.Values.OfType<XmlSchemaComplexType>()).Where(t => t.QualifiedName.Namespace.StartsWith("http://schemas.datacontract.org/2004/07/")))
        {
            complexType.Attributes.Add(new XmlSchemaAttribute { RefName = new XmlQualifiedName("Id", "http://schemas.microsoft.com/2003/10/Serialization/") });
            complexType.Attributes.Add(new XmlSchemaAttribute { RefName = new XmlQualifiedName("Ref", "http://schemas.microsoft.com/2003/10/Serialization/") });
        }
    }

生成WSDL时,甚至都不会调用GetCustomDataToExport。 干得好,再次,MS。

暂无
暂无

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

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