26

I was exploring Swagger and I must acknowledge I'm loving it.

I understand Swagger is primarily for RESTful web services, but I was wondering if we can make it work with SOAP web services as well. May be translate SOAP based web services to RESTful? Or simply call SOAP based services via Swagger UI? Some hack? Has anyone done it?

4

4 回答 4

8

根据目前的规范,我不这么认为。大摇大摆地提及 WSDL 的各个方面并不容易

仅举几例:

  1. 端口类型
  2. 请求和响应消息的模式和命名空间
  3. SOAP 编码(RPC/文字等)
于 2014-09-11T04:48:58.557 回答
1

这可能值得一试:Swagger 连接器Preparing API for consumption

有一个用于指向 SOAP WSDL 以通过 Loopback 服务器公开它的模块:http: //strongloop.com/strongblog/soap-into-rest-apis-with-loopback-node-js/

作为粘合现有数据源和新数据源的 API 服务器,LoopBack 旨在促进您的后端数据集成。随着 loopback-connector-soap 模块的发布,您现在可以轻松地使用 SOAP Web 服务并将它们转换为 REST API。

我还不能确认它是否有效,但它看起来像是一种使用 Swagger 公开 SOAP 服务的方式。

于 2015-02-10T16:42:00.920 回答
1

在线“将基于 SOAP 的 Web 服务转换为 RESTful”正是DreamFactory所做的。基于 Swagger 的开源 API 管理工具。在这里,您可以了解 SOAP-to-REST 功能。

于 2017-02-07T18:18:54.350 回答
0

openapi: 3.0.1

info:

  version: 1.0.0
  title: SOAP
  description: |-
    # Introduction
    > ## 1.1. Purpose

    IMG
    >>> ![Service description](./IMGs/ServiceDescription.png)


    TABLE
    >>>>| TH1             | TH2           |  TH3          | TH4         |
    >>>>| --------------- | ------------- | ------------- | ----------- |
    >>>>| Body1           | Body1         | Body3         | Body4       |



  termsOfService: https://anas.badwais.com/en/terms-conditions
  contact:
    email: itconsultant89@anas.badwais.com
  license:
    name: Anas Badwais
    url: http://anas.badwais.com/licenses/LICENSE-2.0.html
externalDocs:
  description: Service description (WSDL)
  url:  'http://WSDL_URL/?wsdl'
servers:
  - description: testing
    url: '{protocol}{Environment}{port}{version}'
    variables:
      protocol:
        enum:
          - 'https://'
          - 'http://'
        default: 'http://'
      Environment:
        enum:
          - 'IPAddress'
        default: 'IPAddress'
      port:
        enum:
          - 'Port'
        default: 'Port'
      version:
        enum:
          - 'Version'
        default: 'Version'

tags:
  - name: tagName
    externalDocs:
      description: Find out more
      url: ''
paths:
  /{OperationName}/:
    post:
      tags:
        - tagName
      summary: OperationName - Breif Description
      description: |-
        description
      operationId: OperationName
      parameters:
        - description: OperationName
          name: OperationName
          required: true
          in: path
          schema:
            type: string
            enum:
              - 'SOAPURL_IF_EXISTS'
            default: 'SOAPURL_IF_EXISTS'
        - description: SOAPAction header for soap 1.1
          name: SOAPAction
          required: true
          in: header
          schema:
            type: string
            enum:
              - OperationName
            default: OperationName
      requestBody:
        $ref: '#/components/requestBodies/OperationNameEnvelope'
      responses:
        '200':
          description: OK
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: string
            Access-Control-Allow-Methods:
              schema:
                type: string
            Access-Control-Allow-Headers:
              schema:
                type: string
            Transfer-Encoding:
              description : chunked
              schema:
                type: string
          content:
            text/xml charset=UTF-8 :
              schema:
                $ref: '#/components/schemas/OperationNameResponseEnvelope'
              examples:
                HappyScenario:
                  $ref: '#/components/examples/OperationName_RS_HappyScenario'

        '500':
          description: Internal Server Error
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: string
            Access-Control-Allow-Methods:
              schema:
                type: string
            Access-Control-Allow-Headers:
              schema:
                type: string
            Transfer-Encoding:
              description: chunked
              schema:
                type: string
          content:
            text/xml charset=UTF-8:
              schema:
                $ref: '#/components/schemas/faultEnvelope'
      # security:

components:
  examples:
    OperationName_HappyScenario:
      value:
        Header:
        Body:
          OperationName: '1'

    #-----------------#
    #----------------------------------#

    OperationName_RS_HappyScenario:
      value:
        Header:
        Body:
          OperationName: '1'

  #-----------------#
  #----------------------------------#
  #-----------------#

  requestBodies:
    OperationNameEnvelope:
      description: ''
      content:
        text/xml charset=UTF-8:
          schema:
            $ref: '#/components/schemas/OperationNameEnvelope'
          examples:
            HappyScenario:
              $ref: '#/components/examples/OperationName_HappyScenario'


    #-----------------#
    #----------------------------------#
    #-----------------#

  schemas:
    OperationNameEnvelope:
      type: object
      xml:
        name: Envelope
        prefix: soapenv
        namespace: 'http://schemas.xmlsoap.org/soap/envelope/'
      properties:
        Header:
          type: string
          xml:
            name: Header
            prefix: soapenv
          example:
        Body:
          type: object
          xml:
            name: Body
            prefix: soapenv
          properties:
            OperationNameRequestMessage:
              $ref: '#/components/schemas/OperationNameRequestMessage'

    #-----------------#

    OperationNameRequestMessage:
      type: object
      xml:
        prefix: tns
        namespace: 'https://anas.badwais.com/'
      properties:
        OperationElement:
          type: number

    #-----------------#
    #----------------------------------#
    #-----------------#

    OperationNameResponseEnvelope:
      type: object
      xml:
        name: Envelope
        prefix: soapenv
        namespace: 'http://schemas.xmlsoap.org/soap/envelope/'
      properties:
        Header:
          type: string
          description: ''
          xml:
            prefix: soapenv
          example:
        Body:
          type: object
          description: ''
          xml:
            prefix: soapenv
          properties:
            OperationNameResponseMessage:
              $ref: '#/components/schemas/OperationNameResponseMessage'

    #-----------------#

    OperationNameResponseMessage:
      type: object
      description: ''
      required:
        - Response
      xml:
        prefix: tns
        namespace: 'https://anas.badwais.com/'
      properties:
        ResponseElements:
          type: integer

    #-----------------#
    #----------------------------------#
    #-----------------#

    faultEnvelope:
      type: object
      xml:
        name: Envelope
        prefix: soapenv
        namespace: 'http://schemas.xmlsoap.org/soap/envelope/'
      properties:
        Header:
          type: object
          xml:
            name: Header
            prefix: soapenv
        Body:
          type: object
          xml:
            name: Body
            prefix: soapenv
          properties:
            getVisitorInfo:
              $ref: '#/components/schemas/fault'

    #-----------------#

    fault:
      type: object
      xml:
        name: Fault
        prefix: soapenv
        namespace: 'http://schemas.xmlsoap.org/soap/envelope/'
      properties:
        faultcode:
          type: string
          xml:
            name: faultcode
          example: 1
        faultstring:
          type: string
          xml:
            name: faultstring
          example: Error
        faultactor:
          type: string
          xml:
            name: faultactor
          example: 1
        detail:
          type: object
          xml:
            name: detail
          properties:
            Fault:
              $ref: '#/components/schemas/FaultBody'

    #-----------------#

    FaultBody:
      type: object
      xml:
        name: Fault
        prefix: flt
        namespace: 'http://schemas.xmlsoap.org/soap/envelope/'
      properties:
        ErrorCode:
          type: integer
          format: int64
          xml:
            name: Fault
            prefix: flt
          example: 1
        ErrorType:
          type: string
          xml:
            name: Fault
            prefix: flt
          enum:
            - System
            - Functional
        Message:
          type: string
          xml:
            name: Fault
            prefix: flt
          example: error

  # securitySchemes:

于 2021-06-16T12:19:00.223 回答