Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Legacy SOAP services are still prevalent on the web. Enabling SOAP web services in REST APIs provides allows you to take advantage of these services in your REST API endpoints. You can use a Proxy to connect to a SOAP web service and apply API policies against it. In the Create Endpoint dialog, you can easily define parts of the SOAP payload to be dynamically provided by an incoming query parameter or header from the request to execute the Proxy endpoint. This capability enables you to take advantage of the SnapLogic server for your SOAP endpoints and expose them to REST clients.

Benefits

Listed are the benefits of publishing Proxies on your Developer Portal to expose SOAP endpoints:

  • Developers now have access to more user-friendly REST APIs.

  • The transition from SOAP to REST improves overall integration efficiency and performance.

  • The APIM solution provides a centralized platform for managing and monitoring the APIs.

How it works

The Proxy API always treats the SOAP endpoint as a POST call. To turn the SOAP envelope into an HTTP service, the endpoint requires the payload the user wants to submit. This is accomplished via the SOAP parameters. These are added to the Proxy endpoint URI as a query parameter. The response is returned as a REST response. Because you might want to know the definitions of all your existing SOAP endpoints, you can compile them in one XML file. The endpoints broadcast the SOAP XML payloads for the client.

Learn more about how to expose your SOAP endpoints as REST calls in this example.

Prerequisites

  • Org Admin permissions

...

  1. In the API Manager, open a Proxy for editing, then go to the Proxy Endpoints tab.

  2. Click (blue star) to open the Create Proxy Endpoint dialog.

  3. Configure the new endpoint:

Field

Description

Endpoint Name

The name for your proxy's endpoint:

  • Must be unique.

  • Must begin with alphanumeric characters A-Z, a-z, or 0-9.

  • Cannot contain the reserved keyword shared.

  • Cannot contain the following characters:
    | < > [ ] { } # ? / \

  • Must be no more than 256 characters. If the name includes double-byte characters, the maximum length is shorter.

URL

The URL to which users send their requests.

Example: https://www.example.com/path/to/the/api

HTTP Method(s)

One or more REST methods for the API that this endpoint will service.

  • Get

  • Put

  • Head

  • Post

  • Patch

  • Delete

Trust all Certificates

Select this checkbox to run the API calls regardless of the certificate status. If you leave this checkbox deselected (default setting), any endpoint with an expired or unsigned certificate will fail the API call.

REST to SOAP

Select this checkbox to enable a SOAP payload as a REST HTTP call. When selected, the SOAP payload filed appears. The derfault setting is unselected.

Info

The REST to SOAP checkbox only supports incoming GET requests by default. The HTTP method cannot be modified and will always call the SOAP endpoint with a POST.

Image Modified

Example of a valid SOAP payload:

<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body>
  <m:GetPriceResponse xmlns:m="https://www.w3schools.com/prices">
    <m:Price>UnitPrice</m:Price>
  </m:GetPriceResponse>
</soap:Body>

</soap:Envelope>

Instead of a static value for Price, you can insert a key, such as UnitPrice, where the value can be defined from the request. The endpoint https://snaplogic.io/gateway/MyProxy/MyProxyEndpoint?UnitPrice=10.99 would be replaced in the payload at runtime as 10.99 instead of UnitPrice or a static value.

Anchor
edit-endpoint
edit-endpoint
Editing an Endpoint

...

  1. In the API Manager, open a proxy for editing, then go to the Proxy Endpoints tab.

  2. Click the endpoint's name in the list.

    Edit Proxy EndpointImage RemovedEdit Proxy EndpointImage Added

    Learn more: Proxy Endpoint Details.

  3. To edit the proxy details, click the Edit Details button.

    Note: You can update only the URL and HTTP Method(s) of the endpoint.

  4. To apply security policies to the endpoint, click the plus icon ( (blue star) ) below the View Applied Policies button.

...

  1. In the API Manager, open a proxy for editing, then go to the Proxy Endpoints tab.

  2. Check the box for the endpoint to delete.

  3. Click the trash icon ( (blue star) ). The Delete confirmation message appears:

  4. Click Delete.

  5. Verify the deleted Assets by navigating to the Manager Recycle Bin for your Org.

  6. To delete forever:

    1. Select the endpoint.

    2. Click (blue star) to delete it permanently from the Manager Recycle Bin.

...

REST to SOAP Tutorial

In this tutorial, we will complete the following tasks using SnapLogic APIM:

  • Create a REST endpoint for our SOAP service

  • Expose the SOAP service to our API consumers

  • Demonstrate how to call the API

For example, the following SOAP envelope, http://www.dneonline.com/calculator.asmx, performs a multiplication operation for two variables. To use our SOAP to REST service, supply the SOAP envelope to access the service. We supply the variables that will be parameterized into query strings key-value pairs.

Code Block
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Multiply xmlns="http://tempuri.org/">
      <intA>n1</intA>
      <intB>n2</intB>
    </Multiply>
  </soap:Body>
</soap:Envelope>

Here, the variables are n1 and n2, which must be integers.

The resulting REST endpoint looks like this:
https://cloud-dev-fm.snaplogic.io/gateway/Multiplier/Multiply?n1=xx&n2=yy

Where xx and yy are the specified integers.

The query parameters n1 and n2 are the key-value pairs that represent the numbers that will be multiplied by the SOAP service. The REST API response returns the product.

Create a REST endpoint for a SOAP service

We start in APIM by creating the API Proxy that generates the REST endpoints for the SOAP service.

  1. In API Manager, click (blue star) to add a new proxy.

  2. In the Create Proxy wizard, click Create Empty Proxy.

  3. Name the proxy, provide a description, enter tags, and click Create with endpoints.

    apim-create-proxy-soap-multiplier-example.pngImage Added

  4. In the Create proxy endpoint dialog, add endpoint details:

    apim-create-proxy-endpoint-soap-payload-example.pngImage Added
    1. Name the endpoint and add the URL.

    2. Click REST to SOAP, then enter the SOAP envelope.
      Tip: You paste the payload in the window instead of typing it.

    3. Click Create.

  5. In the Endpoint URLs screen, do the following:

    apim-proxy-urls-soap-multiplier.pngImage Added
    1. Using the Snaplex picker, select the server to run the Proxy API. Here, we selected cloud-dev.

    2. Copy the endpoint URL.

    3. Click Close

Expose the SOAP service to API consumers

In this part of the tutorial, we expose the SOAP service by publishing it on the Developer Portal.

To enable all users the ability to test your API from the portal, add Authorize by Role and Anonymous Authenticator policies.

  1. In the Proxy tab, click Generate Specification,

    1. Select specification type: (OAS 2.0/3.0)

    2. Select format: (JSON/YAML)

    3. Click Publish.
      For this example, we selected OAS 2.0 for the specification type and YAML for the file format.

  2. In the Publish dialog, select File from Proxy, and then choose the generated file from the dropdown picker.

    1. Click (blue star) to open the Swagger specification editor.

    2. In the specification, add the following field to the specification, paste the endpoint URL, then edit as shown in the following image:

      apim-spec-proxy-soap-host-param-example.pngImage Added

      Here both the host and parameters are specified.

    3. Click Save.

    4. Enter the remaining publication details in the dialog, and publish the Proxy.

Demonstrate how to call the API

  1. Navigate to your Developer Portal and view the Proxy.
    Note that the SOAP service displays as an API with a REST endpoint.

    apim-devportal-soap-endpoint-details.pngImage Added
  2. To test the proxy, call the API using your method of preference and specify the query parameter:
    https://cloud-dev-fm.snaplogic.io/gateway/Multiplier/Multiply?n1=xx&n2=yy

    CURL command example:

    Code Block
    curl -X 'GET' \
      'https://cloud-dev-fm.snaplogic.io/gateway/Multiplier/Multiply?n1=5&n2=300' \
      -H 'accept: application/json'

    Response:

    Code Block
    {"Body":{"MultiplyResponse":{"MultiplyResult":"1500"}}}%   

The following repeating video demonstrates how an API consumer would test the service using the Try it out functionality available in the Developer Portal:

...