【问题标题】:How can i convert wsdl to XSD type format?如何将 wsdl 转换为 XSD 类型格式?
【发布时间】:2011-08-10 05:09:50
【问题描述】:

我有 wsdl 格式的 XML,现在我想将它的编码更改为 XSD 格式。我是否需要在网络配置中进行一些更改,或者我必须做什么请建议我。 下面是例子

<wsdl:definitions name="LoginCheck"
                  targetNamespace="http://tempuri.org/">
    <wsdl:types>
        <xsd:schema targetNamespace="http://tempuri.org/Imports">
            <xsd:import schemaLocation="http://192.168.0.6:8000/LoginCheck.svc?xsd=xsd0"
                        namespace="http://tempuri.org/"/>
            <xsd:import schemaLocation="http://192.168.0.6:8000/LoginCheck.svc?xsd=xsd1"
                        namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>

我想将其转换为如下格式

<definitions targetNamespace="urn:saveCharacterAcc">
    <types>
        <xsd:schema targetNamespace="urn:saveCharacterAcc">
            <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
            <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
            <xsd:complexType name="Character">
                <xsd:all>
                    <xsd:element name="characterNumber"
                                 type="xsd:int"/>
                    <xsd:element name="byteArray"
                                 type="xsd:string"/>
                    <xsd:element name="rotationAngle"
                                 type="xsd:string"/>
                    <xsd:element name="charX" type="xsd:string"/>

【问题讨论】:

  • 有人能告诉我更多吗?

标签: xsd wsdl


【解决方案1】:

这不是一个简单的方法,但您可以尝试使用 wsdl 工具(或用于 WCF 的 svcutil)生成 C# 类,然后使用 xsd 工具从这些类生成 XSD。

【讨论】:

    【解决方案2】:

    为了解决这个问题,我使用了带有以下 XSL 代码的 XSL 转换器。

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
            version="1.0">
        <xsl:output method="xml" indent="yes"/>
    
        <xsl:template match="wsdl:types">
            <xsl:copy-of select="xs:schema"/>
        </xsl:template>
        <xsl:template match="wsdl:documentation/text()"/>
    </xsl:stylesheet>
    

    &lt;xsl:template match="wsdl:documentation/text()"/&gt; 标记用于删除一些不需要的文本元素,这些元素出现在我生成的 XSD 文件中。

    【讨论】:

      猜你喜欢
      • 2010-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 1970-01-01
      • 2012-06-15
      • 2019-02-19
      • 2011-12-22
      相关资源
      最近更新 更多