# REST to SOAP

#### Bi-Direct endpoint for REST to SOAP: [https://tri-way.vercel.app/resttosoap](#bi-direct-endpoint-for-rest-to-soap-https-tri-way.vercel.app-resttosoap)

Just like a REST API call if you want to pass any data and the required data in the request body, you need to include a JSON object with the following keys:

* **Url**: The endpoint URL of the SOAP 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 POST request

#### Normally this is how a soap request looks like

```
Host: www.dataaccess.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
```

```xml
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
      <ubiNum>1234</ubiNum>
    </NumberToWords>
  </soap12:Body>
</soap12:Envelope>
```

Output for the above-given soap request will look something like this

```xml
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <NumberToWordsResponse xmlns="http://www.dataaccess.com/webservicesserver/">
      <NumberToWordsResult>one thousand two hundred and thirty four</NumberToWordsResult>
    </NumberToWordsResponse>
  </soap12:Body>
</soap12:Envelope>
```

#### Example of a POST request made using Bi-Direct

#### Headers

{% code overflow="wrap" lineNumbers="true" %}

```javascript
headers: {
    'Content-Type': 'application/json'
  }
```

{% endcode %}

#### Request Body (POST request)

{% hint style="info" %}

#### Note

The input data for the SOAP request is specified in the `"Data"` property. The `"NumberToWords"` property specifies the name of the SOAP operation, and the `ubiNum` property specifies the input parameter. The `"#"` property specifies the value of the input parameter, which is `unsignedLong`. The `"@"` the property specifies the namespace declaration for the `NumberToWords` element.
{% endhint %}

{% code lineNumbers="true" %}

```json
{
  "Url": "https://www.dataaccess.com//webservicesserver/NumberConversion.wso?op=NumberToWords",
  "Method": "POST",
  "Data": {
    "NumberToWords": {
      "@": {
        "xmlns": "http://www.dataaccess.com/webservicesserver/"
      },
      "ubiNum": {
        "#": "1234"
      }
    }
  }
}
```

{% endcode %}

<details>

<summary>Generated output for the given POST request</summary>

```json
{
  "soap:Envelope": {
    "$": {
      "xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/"
    },
    "soap:Body": [
      {
        "m:NumberToWordsResponse": [
          {
            "$": {
              "xmlns:m": "http://www.dataaccess.com/webservicesserver/"
            },
            "m:NumberToWordsResult": [
              "one thousand two hundred and thirty four "
            ]
          }
        ]
      }
    ]
  }
}
```

</details>

<details>

<summary>Javascript code (Axios)</summary>

{% code lineNumbers="true" %}

```javascript
let headersList = {
  "Content-Type": "application/json"
 }
 
 let bodyContent = JSON.stringify({
  "Url": "https://www.dataaccess.com//webservicesserver/NumberConversion.wso?op=NumberToWords",
  "Method": "POST",
  "Data": {
    "NumberToWords": {
      "@": {
        "xmlns": "http://www.dataaccess.com/webservicesserver/"
      },
      "ubiNum": {
        "#": "1234"
      }
    }
  }
});

async function makeRequest() { 
 let response = await fetch("https://tri-way.vercel.app/resttosoap", { 
   method: "POST",
   body: bodyContent,
   headers: headersList
 });
 
 let data = await response.text();
console.log(data);
}
 
makeRequest()
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://triway.gitbook.io/bi-direct/rest-to-soap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
