27

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?

pavanlimo
  • 4,122
  • 3
  • 32
  • 47
  • I am using wcfextras (http://wcfextras.codeplex.com/) to enrich and extract automatically documentation in a WCF service. the ouput is a .xml file with the documented service, though it is possible to attach an XSLT template to display it as a html. Other tools I have seen are commercial. – willyMon May 04 '16 at 22:33

4 Answers4

8

Based on the present spec, I do not think so. It would not be easily possible to mention various aspects of a WSDL in swagger

To name a few:

  1. PortTypes
  2. Schemas and namespaces of request and response messages
  3. SOAP encodings (RPC/Literal etc.)
Santanu Dey
  • 2,900
  • 3
  • 24
  • 38
1

This might be worth a try: Swagger connector and Preparing the API for consumption.

There is a module for pointing at a SOAP WSDL to expose it through a Loopback server: http://strongloop.com/strongblog/soap-into-rest-apis-with-loopback-node-js/

As an API server to glue existing and new data sources, LoopBack is designed to facilitate your backend data integration. With the release of loopback-connector-soap module, you can now easily consume SOAP web services and transform them into REST APIs.

I can't yet confirm that it works, but it looks like a way of exposing a SOAP service using Swagger.

TravisO
  • 9,406
  • 4
  • 36
  • 44
Martin Dow
  • 5,273
  • 4
  • 30
  • 43
1

online "translate SOAP based web services to RESTful" is what exactly DreamFactory does. Open Source API management tool based on Swagger. Here you can read about SOAP-to-REST functionality.

Dima Fomin
  • 1,228
  • 1
  • 16
  • 27
-2

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:
NoOoNY
  • 15
  • 4
  • 5
    Welcome to Stack Overflow. Code without any explanation are rarely helpful. Stack Overflow is about learning, not providing snippets to blindly copy and paste. Please edit your question and explain how it answers the specific question being asked. See [How to Answer](https://stackoverflow.com/help/how-to-answer). – Sfili_81 Jun 16 '21 at 13:12