2011-08-10 82 views
2

我使用wsdl格式的XML,现在我想将其编码更改为格式XSD格式。我是否需要在Web配置中进行一些更改,或者我需要做什么请给我建议。下面 是例如何将wsdl转换为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"/> 
+1

有些身体可以告诉我更多关于它吗? – NoviceToDotNet

+1

我可以期待更多答案吗? – NoviceToDotNet

回答

2

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

0

为了解决这个问题,我使用了一个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> 

<xsl:template match="wsdl:documentation/text()"/>标签被用来去除一些不良文字元素,出现在我的生成的XSD文件。