Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This feature allows users to expose their legacy SOAP backends as REST APIs through WSO2 API Manager. WSO2 API Manager supports WSDL 1.1 based SOAP backends.

The following instructions explain how to generate REST APIs in WSO2 API Manager for an existing SOAP backend.

Before you begin...

Make sure that you have a valid WSDL URL from the SOAP backend. It should belong to the WSDL 1.1 version. 

  1. Log in to the API Publisher and click ADD NEW API
  2. Select I Have a SOAP Endpoint. You see the following two options to create APIs for SOAP backend.
    • Pass Through – Create a pass through proxy for SOAP requests coming to the API Gateway.
    • Generate REST APIs – This option is used to generate REST API definitions from the given WSDL URL.
  3. Select Generate REST APIs. Provide the WSDL URL given below for the SOAP backend and click Start Creating

    Sample WSDL URL
    http://ws.cdyne.com/phoneverify/phoneverify.asmx?wsdl

    The default option is Pass Through.

  4. Go to the Design tab. Click on Edit Source to edit the Swagger specification of the API.

    Copy and paste the following code

    swagger: "2.0"
    paths:
      /CheckPhoneNumber:
        get:
          responses:
            "200":
              description: ""
          produces:
            - application/xml
          consumes:
            - application/json
          parameters:
            - name: Phone Number
              in: query
              required: true
              type: string
              description: "Give the phone number to be validated"
            - name: "LicenseKey"
              in: query
              required: true
              type: string
              description: "Give the license key as 0 for testing purpose"
        post:
          parameters:
            - name: Payload
              description: Request Body
              required: false
              in: body
              schema:
                type: object
                properties:
                  payload:
                    type: string
          responses:
            "200":
              description: ""
    info:
      title: PhoneVerification
      version: 1.0.0
  5. Click Apply Changes to save your API.
  6. The generated API definitions are added to the API as shown below.

    The definition properties are mapped with a Swagger vendor-specific field x-xpath, which is used to map the SOAP binding operation parameters with the REST parameters. If a parameter does not have this field it is not mapped with a backend operation. To ensure the mapping functions smoothly, do not make any changes to the properties.

  7. Go to the Implement tab and view the SOAP Mapping section. Click on a resource to view the In and Out sequences of the API.
  8. The following sample shows the generated API In-sequence for a GET method with query parameters.

    GET https://<host_name>:8243/phoneverify/1.0.0/CheckPhoneNumber?Phone%20Number=XXXXXXXX&LicenseKey=0
    <header description="SOAPAction" name="SOAPAction" scope="transport" value="http://ws.cdyne.com/PhoneVerify/query/CheckPhoneNumber"/>
    <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
    <property expression="$url:PhoneNumber" name="req.var.PhoneNumber"/>
    <property expression="$url:LicenseKey" name="req.var.LicenseKey"/>
    
    
    <payloadFactory description="transform" media-type="xml">
      <format>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://ws.cdyne.com/PhoneVerify/query">
      <soapenv:Header/>
      <soapenv:Body>
      	<web:CheckPhoneNumber xmlns:web="http://ws.cdyne.com/PhoneVerify/query">
       <web:PhoneNumber>$1</web:PhoneNumber>
       <web:LicenseKey>$2</web:LicenseKey>
    </web:CheckPhoneNumber>
    
      </soapenv:Body>
      </soapenv:Envelope>
      </format>
      <args>
     	<arg evaluator="xml" expression="get-property('req.var.PhoneNumber')"/>
    <arg evaluator="xml" expression="get-property('req.var.LicenseKey')"/>
    
      </args>
    </payloadFactory>
    <property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>

    The incoming JSON message parameters are stored using properties. The SOAP payload needed for the backend is generated using a payload factory mediator.

  9. Enter the SOAP endpoint URL. The endpoint type should be the HTTP/SOAP Endpoint as shown below.

    SOAP Endpoint URL
    http://ws.cdyne.com/phoneverify/phoneverify.asmx


  10. Go to the Manage tab and select the relevant configurations. Click Publish to publish the API to the API Store. For instructions, see Create and Publish an API.
  11. Navigate to the API Store and invoke the API. 
  • No labels