@ Liên kết Grinn đã chết và googling CustomWsdlHelpGenerator.aspx không biến bất kỳ thứ gì hữu ích. Nhưng tôi đi qua này:
Improving the ASP.NET Webservice Help Generator
Nó sử dụng cách tiếp cận @Grinn đề cập đến và sử dụng một XSL để chuyển đổi dữ liệu WSDL để phản ánh thừa kế.
Từ liên kết:
Lấy cài đặt máy phát điện mô tả mặc định DefaultWsdlHelpGenerator.aspx (trên máy tính của tôi, đó là trong C: \ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG) và lưu nó như WsdlHelpGenerator .aspx trong thư mục web của dịch vụ web của bạn. Mở web.config của bạn và đặt ...
<webServices>
<wsdlHelpGenerator href="WsdlHelpGenerator.aspx" />
</webServices>
... bên trong '<system.web>' phần.
mở WsdlHelpGenerator.aspx và thêm hai phương pháp trực tiếp dưới phương pháp Page_Load:
protected override void OnPreLoad(EventArgs e) {
base.OnPreLoad(e);
// transform any service description stored within HttpContext
// cf. Page_Load: try "wsdlsWithPost" first and fall back to "wsdls"
string key = Context.Items["wsdlsWithPost"] != null ?
"wsdlsWithPost" : "wsdls";
serviceDescriptions = (ServiceDescriptionCollection)Context.Items[key];
TransformServiceDescriptions(ref serviceDescriptions);
Context.Items[key] = serviceDescriptions;
}
void TransformServiceDescriptions(ref ServiceDescriptionCollection descriptions) {
// modify each description by an XSLT processor
ServiceDescriptionCollection transformed = new ServiceDescriptionCollection();
System.Xml.Xsl.XslCompiledTransform xslt =
new System.Xml.Xsl.XslCompiledTransform();
xslt.Load(Server.MapPath("WsdlHelp.xsl"));
foreach (ServiceDescription desc in descriptions)
{
// load original WSDL data
MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream();
desc.Write(ms1);
// process WSDL data using WsdlHelp.xsl
ms1.Position = 0;
xslt.Transform(new System.Xml.XPath.XPathDocument(ms1), null, ms2);
// replace current WSDL data with the transformed stream
ms2.Position = 0;
transformed.Add(ServiceDescription.Read(ms2));
ms1.Dispose();
ms2.Dispose();
}
descriptions = transformed;
}
Cuối cùng, để có được mã này làm việc, đặt các tập tin chuyển đổi WsdlHelp.xsl vào thư mục web của webservice của bạn. Nó có thể trông như sau:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="http://www.w3.org/2001/XMLSchema">
<xsl:output
method="xml"
indent="no"
encoding="utf-8"
omit-xml-declaration="no"
/>
<!-- recursively dissolve any schema extension elements to the base structure -->
<xsl:template match="/" xml:space="default">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="*" priority="0.5" xml:space="default">
<xsl:copy>
<xsl:copy-of select="attribute::*" />
<xsl:choose>
<xsl:when test="child::*" />
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="child::*" />
</xsl:copy>
</xsl:template>
<xsl:template match="s:complexType" priority="1.0">
<xsl:element name="s:complexType" namespace="http://www.w3.org/2001/XMLSchema">
<xsl:copy-of select="attribute::*" />
<xsl:element name="s:sequence">
<xsl:copy-of select=".//s:sequence/*" />
<xsl:if test="./s:complexContent/s:extension">
<xsl:comment> schema extension expanded: <xsl:value-of
select="./s:complexContent/s:extension/@base"/> </xsl:comment>
<xsl:call-template name="fetch-sequence">
<xsl:with-param name="typename"
select="substring-after(./s:complexContent/s:extension/@base,':')" />
</xsl:call-template>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template name="fetch-sequence">
<xsl:param name="typename" />
<xsl:copy-of select="//s:complexType[@name = $typename]//s:sequence/*" />
<xsl:if test="//s:complexType[@name = $typename]/s:complexContent/s:extension">
<xsl:call-template name="fetch-sequence">
<xsl:with-param name="typename"
select="substring-after(//s:complexType[@name = $typename]
/s:complexContent/s:extension/@base,':')" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Ah, "Good Times Jelly Donut Denny Bug" đình công lần nữa :) –