【问题标题】:How to generate WSDL (WSDL 2.0) for a RESTfull webservice如何为 RESTful Web 服务生成 WSDL (WSDL 2.0)
【发布时间】:2016-02-25 00:29:05
【问题描述】:

我正在寻找一种方法来在 php 中为我的 RESTfull 网络服务生成一个 WSDL(WSDL2) 网络服务描述符。

我知道 RESTfull webservice 不需要像 SOAP 这样的描述,但我需要 REST WS 的 WSDL 来为 webservice 添加语义注释。

【问题讨论】:

    标签: web-services rest annotations semantic-web wsdl-2.0


    【解决方案1】:

    您可以为此使用tinyWSDL

    先看看here。 如果您使用 XML Schema,您可以添加 DOM 元素或使用 tinyXMLSchema 插件(+ Apache XML Schema 2.1 libaray)。

    Types types = description.getTypes();
    SchemaTypesExtensions extensions = (SchemaTypesExtensions)types.getComponentExtensions(WSDLPredefinedExtension.SCHEMA.URI);
    Schema schema = extensions.newSchema();
    

    // 在这里你可以创建一个新的 Schema XmlSchema xmlSchema = (XmlSchema)schema.getSchema();

    // 或设置已解析的一个: schema.setSchema(xmlSchema)

    如果您不想使用 Apache XML Shcema 库,您可以随时使用 DOM 元素:

    types.addExtensionElement(new QName("http://www.w3.org/2001/XMLSchema", "schema", "xs"), element)
    

    干杯,

    D.

    附:源代码中还有 WSDL 2.0 -> WADL 转换器(不在 jar 中)。

    【讨论】:

      猜你喜欢
      • 2010-11-26
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-02
      相关资源
      最近更新 更多