【问题标题】:Creating a comment that gets displayed in generated request? WSDL SOAP xml创建在生成的请求中显示的评论? WSDL SOAP xml
【发布时间】:2018-07-26 13:47:45
【问题描述】:

我正在为现有系统编写wsdl 文件。我想将 cmets 添加到生成的请求中。

例如:

    <xsd:simpleType name="coffeetype">
        <xsd:restriction base="xsd:integer">
            <!--0=likescoffee,1=doesnotlikecoffe-->
            <xsd:enumeration value="0" />
            <xsd:enumeration value="1" />
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:element name="CoffeeRequestInput" nillable="false" type="tns:coffeetype" />

在生成的请求中应该如下所示:(例如,在 SoapUI 中加载 WSDL 时)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="https://example.com/some.wsdl">
   <soapenv:Header/>
   <soapenv:Body>
      <!--0=likescoffee,1=doesnotlikecoffe-->
      <wsdl:CoffeeRequestInput>0</wsdl:CoffeeRequestInput>
   </soapenv:Body>
</soapenv:Envelope>

我在打开WSDL 时能够看到这些cmets,但在从WSDL 生成请求时却看不到。

已经查看了注释,但我无法使用它们来创建我想要的结果。 (可能是我这边的错误)

【问题讨论】:

  • 您可以使用 xsd:documentation 标签将文档添加到您的 xsd。请参阅此链接w3schools.com/xml/el_documentation.asp。这是记录您的请求、回复和结构的标准方式。但它不会出现在请求中。
  • @Namphibian 我明白了。所以不可能将 cmets 添加到生成的请求中?
  • 不是。但是,您可以使用一些 xslt 和这些注释来生成一些关键文档。
  • @Namphibian 请将其写为答案,以便我接受。
  • 我已经这样做了。

标签: soap wsdl soapui


【解决方案1】:

简而言之,您无法按照自己的意愿在请求中创建文档。但是,您可以从您的 WSDL 生成非常有用的文档。通过使用“xsd:documentation”标签,您可以将文档直接添加到元素中。

例如

<xsd:simpleType name="coffeetype">
    <xsd:restriction base="xsd:integer">

        <xsd:enumeration value="0" />
        <xsd:enumeration value="1" />
    </xsd:restriction>
</xsd:simpleType>
<xsd:element name="CoffeeRequestInput" nillable="false" type="tns:coffeetype">
    <xsd:annotation>
        <xsd:documentation>
          This object is the CoffeeRequestInput object is an Enumeration which can be used to determine is the user sending the request likes coffee or not. 
           Valid values for the enumeration is as follows:
           0 = like coffee
           1 = does not like coffee (probably a user not a programmer making a request).
           Some other things that you need to document goes here.
        </xsd:documentation>   
    </xsd:annotation>
</xsd:element>

然后,您可以使用 Altova StyleForce、LiquidXML 和 OxyGen 等软件生成 PDF、Word 文档或 HTML 页面,其中显示了包含所有 cmets 的 SOAP 服务和操作。

如果您愿意,您可以编写自己的 XLST 来将您的 WSDL 和 XSD 转换为一个简洁的 HTML 页面,该页面也记录您的接口。最好的一点是,当您使用新操作更新 WSDL 时,文档也会随之更新。

【讨论】:

    猜你喜欢
    • 2014-05-22
    • 2014-07-13
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多