soap - 创建在生成的请求中显示的评论? WSDL SOAP XML

标签 soap wsdl soapui

我正在为现有系统编写 wsdl 文件。我想向生成的请求添加评论。

比如这个:

    <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 时能够看到这些注释,但在从该 WSDL 生成请求时却看不到。

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

最佳答案

简而言之,您不能随心所欲地在请求中创建文档。但是,您可以从 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 页面,其中显示 SOAP 服务和操作以及您的所有评论。

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

关于soap - 创建在生成的请求中显示的评论? WSDL SOAP XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51540450/

相关文章:

java - 如何在 Spring WS 中处理语法不正确的 XML?

c# - 在 Windows 8 商店 C# 应用程序 : The base class or interface could not be resolved 中使用 WSDL Web 服务

java - 如何告诉 cxf 将包装器类型保留在方法中?

groovy - 从 SoapUI groovy 脚本中执行 Java jar 文件不起作用

python - suds 库中的自定义身份验证 (Python)

java - 在 Spring-Boot 中为 soap webservice 抛出自定义异常?

xml - 用于读取 xml 文件并使用文件内容更新下一步请求的 Groovy 脚本

rest - 将 SOAP UI 用于 Marklogic SPARQL REST API 时出现问题

xml - SOAP::Lite Perl 模块发送错误的 SOAP 信封命名空间

java - 使用多个 WSDL (xmlbeans) 处理共享命名空间