我正在尝试获取引用我的WCF WSDL的客户端的默认行为,以便在导入的DataContracts上将IsReference设置为true。看起来我应该能够使用带有GetCustomDataToExport的IDataContractSurrogate来完成this...which,这意味着在与WSDL关联的xsd中将以下内容添加到生成的ComplexType中:
<xs:attribute ref="ser:Id" />
<xs:attribute ref="ser:Ref" /> 当然,我从微软那里找不到关于如何使用这种方法的可用文档。MSDN页面说它应该返回一个object...but,根本没有指明这应该be....how无用的对象类型……
在我对此进行反射之前,有谁知道如何使用这种方法吗?
谢谢。
发布于 2011-01-16 08:52:29
最终只使用了一个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/") });
}
}甚至在生成GetCustomDataToExport时都不会调用WSDL。再说一次,干得好。
https://stackoverflow.com/questions/4691033
复制相似问题