SOAP to REST

Examples of how to use Bi-direct to make SOAP API calls to a server that only supports REST requests.

Bi-Direct endpoint for REST to SOAP: https://tri-way.vercel.app/soaptorest

Just like a REST to SOAP API call if you want to describe the properties of the request using three parameters Url, Method and Data (to send for a POST request):

  • Url: The endpoint URL of the REST API you want to use

  • Method: The HTTP method for the API call (POST, GET, PUT, DELETE, etc.)

  • Data (optional): The request body data for the POST or PUT request

Example of a GET request

Normally this is how a REST request looks like

Content-Type: application/json; 
const {default:axios} = require("axios")


async function makeRequest(){
  const response = await axios.get("https://jsonplaceholder.typicode.com/users")
console.log(response.data);
}
makeRequest()
Output for the above-given REST request will look something like this
[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    },
    "phone": "1-770-736-8031 x56442",
    "website": "hildegard.org",
    "company": {
      "name": "Romaguera-Crona",
      "catchPhrase": "Multi-layered client-server neural-net",
      "bs": "harness real-time e-markets"
    }
  },
  {
    "id": 2,
    "name": "Ervin Howell",
    "username": "Antonette",
    "email": "Shanna@melissa.tv",
    "address": {
      "street": "Victor Plains",
      "suite": "Suite 879",
      "city": "Wisokyburgh",
      "zipcode": "90566-7771",
      "geo": {
        "lat": "-43.9509",
        "lng": "-34.4618"
      }
    },
    "phone": "010-692-6593 x09125",
    "website": "anastasia.net",
    "company": {
      "name": "Deckow-Crist",
      "catchPhrase": "Proactive didactic contingency",
      "bs": "synergize scalable supply-chains"
    }
  },
  {
    "id": 3,
    "name": "Clementine Bauch",
    "username": "Samantha",
    "email": "Nathan@yesenia.net",
    "address": {
      "street": "Douglas Extension",
      "suite": "Suite 847",
      "city": "McKenziehaven",
      "zipcode": "59590-4157",
      "geo": {
        "lat": "-68.6102",
        "lng": "-47.0653"
      }
    },
    "phone": "1-463-123-4447",
    "website": "ramiro.info",
    "company": {
      "name": "Romaguera-Jacobson",
      "catchPhrase": "Face to face bifurcated interface",
      "bs": "e-enable strategic applications"
    }
  },
  {
    "id": 4,
    "name": "Patricia Lebsack",
    "username": "Karianne",
    "email": "Julianne.OConner@kory.org",
    "address": {
      "street": "Hoeger Mall",
      "suite": "Apt. 692",
      "city": "South Elvis",
      "zipcode": "53919-4257",
      "geo": {
        "lat": "29.4572",
        "lng": "-164.2990"
      }
    },
    "phone": "493-170-9623 x156",
    "website": "kale.biz",
    "company": {
      "name": "Robel-Corkery",
      "catchPhrase": "Multi-tiered zero tolerance productivity",
      "bs": "transition cutting-edge web services"
    }
  },
  {
    "id": 5,
    "name": "Chelsey Dietrich",
    "username": "Kamren",
    "email": "Lucio_Hettinger@annie.ca",
    "address": {
      "street": "Skiles Walks",
      "suite": "Suite 351",
      "city": "Roscoeview",
      "zipcode": "33263",
      "geo": {
        "lat": "-31.8129",
        "lng": "62.5342"
      }
    },
    "phone": "(254)954-1289",
    "website": "demarco.info",
    "company": {
      "name": "Keebler LLC",
      "catchPhrase": "User-centric fault-tolerant solution",
      "bs": "revolutionize end-to-end systems"
    }
  },
  {
    "id": 6,
    "name": "Mrs. Dennis Schulist",
    "username": "Leopoldo_Corkery",
    "email": "Karley_Dach@jasper.info",
    "address": {
      "street": "Norberto Crossing",
      "suite": "Apt. 950",
      "city": "South Christy",
      "zipcode": "23505-1337",
      "geo": {
        "lat": "-71.4197",
        "lng": "71.7478"
      }
    },
    "phone": "1-477-935-8478 x6430",
    "website": "ola.org",
    "company": {
      "name": "Considine-Lockman",
      "catchPhrase": "Synchronised bottom-line interface",
      "bs": "e-enable innovative applications"
    }
  },
  {
    "id": 7,
    "name": "Kurtis Weissnat",
    "username": "Elwyn.Skiles",
    "email": "Telly.Hoeger@billy.biz",
    "address": {
      "street": "Rex Trail",
      "suite": "Suite 280",
      "city": "Howemouth",
      "zipcode": "58804-1099",
      "geo": {
        "lat": "24.8918",
        "lng": "21.8984"
      }
    },
    "phone": "210.067.6132",
    "website": "elvis.io",
    "company": {
      "name": "Johns Group",
      "catchPhrase": "Configurable multimedia task-force",
      "bs": "generate enterprise e-tailers"
    }
  },
  {
    "id": 8,
    "name": "Nicholas Runolfsdottir V",
    "username": "Maxime_Nienow",
    "email": "Sherwood@rosamond.me",
    "address": {
      "street": "Ellsworth Summit",
      "suite": "Suite 729",
      "city": "Aliyaview",
      "zipcode": "45169",
      "geo": {
        "lat": "-14.3990",
        "lng": "-120.7677"
      }
    },
    "phone": "586.493.6943 x140",
    "website": "jacynthe.com",
    "company": {
      "name": "Abernathy Group",
      "catchPhrase": "Implemented secondary concept",
      "bs": "e-enable extensible e-tailers"
    }
  },
  {
    "id": 9,
    "name": "Glenna Reichert",
    "username": "Delphine",
    "email": "Chaim_McDermott@dana.io",
    "address": {
      "street": "Dayna Park",
      "suite": "Suite 449",
      "city": "Bartholomebury",
      "zipcode": "76495-3109",
      "geo": {
        "lat": "24.6463",
        "lng": "-168.8889"
      }
    },
    "phone": "(775)976-6794 x41206",
    "website": "conrad.com",
    "company": {
      "name": "Yost and Sons",
      "catchPhrase": "Switchable contextually-based project",
      "bs": "aggregate real-time technologies"
    }
  },
  {
    "id": 10,
    "name": "Clementina DuBuque",
    "username": "Moriah.Stanton",
    "email": "Rey.Padberg@karina.biz",
    "address": {
      "street": "Kattie Turnpike",
      "suite": "Suite 198",
      "city": "Lebsackbury",
      "zipcode": "31428-2261",
      "geo": {
        "lat": "-38.2386",
        "lng": "57.2232"
      }
    },
    "phone": "024-648-3804",
    "website": "ambrose.net",
    "company": {
      "name": "Hoeger LLC",
      "catchPhrase": "Centralized empowering task-force",
      "bs": "target end-to-end models"
    }
  }
]

Example of a GET request made using Bi-Direct

Host:https://tri-way.vercel.app/
Endpoint:soaptorest

Headers

headers: {
    'Content-Type': 'text/xml'
  }

Request Body (POST request)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Url>
      https://jsonplaceholder.typicode.com/users
    </Url>
    <Method>GET</Method>
    <Data>akash</Data>
  </soap:Body>
</soap:Envelope>
Generated output for the given POST request
<?xml version="1.0"?>
<xmlData>
    <xmlData>
        <id>1</id>
        <name>Leanne Graham</name>
        <username>Bret</username>
        <email>Sincere@april.biz</email>
        <address>
            <street>Kulas Light</street>
            <suite>Apt. 556</suite>
            <city>Gwenborough</city>
            <zipcode>92998-3874</zipcode>
            <geo>
                <lat>-37.3159</lat>
                <lng>81.1496</lng>
            </geo>
        </address>
        <phone>1-770-736-8031 x56442</phone>
        <website>hildegard.org</website>
        <company>
            <name>Romaguera-Crona</name>
            <catchPhrase>Multi-layered client-server neural-net</catchPhrase>
            <bs>harness real-time e-markets</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>2</id>
        <name>Ervin Howell</name>
        <username>Antonette</username>
        <email>Shanna@melissa.tv</email>
        <address>
            <street>Victor Plains</street>
            <suite>Suite 879</suite>
            <city>Wisokyburgh</city>
            <zipcode>90566-7771</zipcode>
            <geo>
                <lat>-43.9509</lat>
                <lng>-34.4618</lng>
            </geo>
        </address>
        <phone>010-692-6593 x09125</phone>
        <website>anastasia.net</website>
        <company>
            <name>Deckow-Crist</name>
            <catchPhrase>Proactive didactic contingency</catchPhrase>
            <bs>synergize scalable supply-chains</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>3</id>
        <name>Clementine Bauch</name>
        <username>Samantha</username>
        <email>Nathan@yesenia.net</email>
        <address>
            <street>Douglas Extension</street>
            <suite>Suite 847</suite>
            <city>McKenziehaven</city>
            <zipcode>59590-4157</zipcode>
            <geo>
                <lat>-68.6102</lat>
                <lng>-47.0653</lng>
            </geo>
        </address>
        <phone>1-463-123-4447</phone>
        <website>ramiro.info</website>
        <company>
            <name>Romaguera-Jacobson</name>
            <catchPhrase>Face to face bifurcated interface</catchPhrase>
            <bs>e-enable strategic applications</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>4</id>
        <name>Patricia Lebsack</name>
        <username>Karianne</username>
        <email>Julianne.OConner@kory.org</email>
        <address>
            <street>Hoeger Mall</street>
            <suite>Apt. 692</suite>
            <city>South Elvis</city>
            <zipcode>53919-4257</zipcode>
            <geo>
                <lat>29.4572</lat>
                <lng>-164.2990</lng>
            </geo>
        </address>
        <phone>493-170-9623 x156</phone>
        <website>kale.biz</website>
        <company>
            <name>Robel-Corkery</name>
            <catchPhrase>Multi-tiered zero tolerance productivity</catchPhrase>
            <bs>transition cutting-edge web services</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>5</id>
        <name>Chelsey Dietrich</name>
        <username>Kamren</username>
        <email>Lucio_Hettinger@annie.ca</email>
        <address>
            <street>Skiles Walks</street>
            <suite>Suite 351</suite>
            <city>Roscoeview</city>
            <zipcode>33263</zipcode>
            <geo>
                <lat>-31.8129</lat>
                <lng>62.5342</lng>
            </geo>
        </address>
        <phone>(254)954-1289</phone>
        <website>demarco.info</website>
        <company>
            <name>Keebler LLC</name>
            <catchPhrase>User-centric fault-tolerant solution</catchPhrase>
            <bs>revolutionize end-to-end systems</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>6</id>
        <name>Mrs. Dennis Schulist</name>
        <username>Leopoldo_Corkery</username>
        <email>Karley_Dach@jasper.info</email>
        <address>
            <street>Norberto Crossing</street>
            <suite>Apt. 950</suite>
            <city>South Christy</city>
            <zipcode>23505-1337</zipcode>
            <geo>
                <lat>-71.4197</lat>
                <lng>71.7478</lng>
            </geo>
        </address>
        <phone>1-477-935-8478 x6430</phone>
        <website>ola.org</website>
        <company>
            <name>Considine-Lockman</name>
            <catchPhrase>Synchronised bottom-line interface</catchPhrase>
            <bs>e-enable innovative applications</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>7</id>
        <name>Kurtis Weissnat</name>
        <username>Elwyn.Skiles</username>
        <email>Telly.Hoeger@billy.biz</email>
        <address>
            <street>Rex Trail</street>
            <suite>Suite 280</suite>
            <city>Howemouth</city>
            <zipcode>58804-1099</zipcode>
            <geo>
                <lat>24.8918</lat>
                <lng>21.8984</lng>
            </geo>
        </address>
        <phone>210.067.6132</phone>
        <website>elvis.io</website>
        <company>
            <name>Johns Group</name>
            <catchPhrase>Configurable multimedia task-force</catchPhrase>
            <bs>generate enterprise e-tailers</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>8</id>
        <name>Nicholas Runolfsdottir V</name>
        <username>Maxime_Nienow</username>
        <email>Sherwood@rosamond.me</email>
        <address>
            <street>Ellsworth Summit</street>
            <suite>Suite 729</suite>
            <city>Aliyaview</city>
            <zipcode>45169</zipcode>
            <geo>
                <lat>-14.3990</lat>
                <lng>-120.7677</lng>
            </geo>
        </address>
        <phone>586.493.6943 x140</phone>
        <website>jacynthe.com</website>
        <company>
            <name>Abernathy Group</name>
            <catchPhrase>Implemented secondary concept</catchPhrase>
            <bs>e-enable extensible e-tailers</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>9</id>
        <name>Glenna Reichert</name>
        <username>Delphine</username>
        <email>Chaim_McDermott@dana.io</email>
        <address>
            <street>Dayna Park</street>
            <suite>Suite 449</suite>
            <city>Bartholomebury</city>
            <zipcode>76495-3109</zipcode>
            <geo>
                <lat>24.6463</lat>
                <lng>-168.8889</lng>
            </geo>
        </address>
        <phone>(775)976-6794 x41206</phone>
        <website>conrad.com</website>
        <company>
            <name>Yost and Sons</name>
            <catchPhrase>Switchable contextually-based project</catchPhrase>
            <bs>aggregate real-time technologies</bs>
        </company>
    </xmlData>
    <xmlData>
        <id>10</id>
        <name>Clementina DuBuque</name>
        <username>Moriah.Stanton</username>
        <email>Rey.Padberg@karina.biz</email>
        <address>
            <street>Kattie Turnpike</street>
            <suite>Suite 198</suite>
            <city>Lebsackbury</city>
            <zipcode>31428-2261</zipcode>
            <geo>
                <lat>-38.2386</lat>
                <lng>57.2232</lng>
            </geo>
        </address>
        <phone>024-648-3804</phone>
        <website>ambrose.net</website>
        <company>
            <name>Hoeger LLC</name>
            <catchPhrase>Centralized empowering task-force</catchPhrase>
            <bs>target end-to-end models</bs>
        </company>
    </xmlData>
</xmlData>

Last updated