---
title: "Work with SOAP and XML APIs"
slug: "work-with-soap-and-xml-apis"
updated: 2023-02-21T18:41:09Z
published: 2023-02-21T18:41:09Z
canonical: "support.tulip.co/work-with-soap-and-xml-apis"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.tulip.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Work with SOAP and XML APIs

## Overview

*A guide with tips and tricks for working with XML-based APIs*

[Tulip Connectors](https://support.tulip.co/docs/an-overview-of-http-connectors) can be used to interact with many types of external data sources. This article focuses on HTTP APIs that exchange information using [XML](https://en.wikipedia.org/wiki/XML). This category includes [SOAP](https://en.wikipedia.org/wiki/SOAP) APIs.

## Sending XML Data in Tulip

To send XML content in the body of a request, use the `$value$` notation to show that a parameter should be inserted.

For example, with the following in the Request Body field:

```
<soapenv:Envelope  
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  
  xmlns:mes="http://mes.myexample.com"  
  xmlns:get="http://getInfo.mes.myexample.com"  
>  
 <soapenv:Header/>  
 <soapenv:Body>  
   <mes:getInfo>  
     <mes:in0>  
       <get:value1>$input1$</get:value1>  
       <get:value2>$input2$</get:value2>  
     </mes:in0>  
   </mes:getInfo>  
 </soapenv:Body>  
</soapenv:Envelope>
```

and the values `input1` and `input2` as inputs to the Connector Function, a request is made with the values of `input1` and `input2` substituted into the Request Body.

This is shown in the Tulip Connector Function interface below:

![Working with SOAP and XML APIs_229803470.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Working%20with%20SOAP%20and%20XML%20APIs_229803470.png)

## Parsing XML Data in Tulip

### A Simple API Example

Let's start with a simple example response from an XML API.

```
<?xml version="1.0" encoding="UTF-8"?>  
<bookstore>  
  <book category="cooking">  
    <title lang="en">Everyday Italian</title>  
    <author>Giada De Laurentiis</author>  
    <year>2005</year>  
    <price>30.00</price>  
  </book>  
  <book category="children">  
    <title lang="en">Harry Potter</title>  
    <author>J K. Rowling</author>  
    <year>2005</year>  
    <price>29.99</price>  
  </book>  
  <book category="web">  
    <title lang="en">Learning XML</title>  
    <author>Erik T. Ray</author>  
    <year>2003</year>  
    <price>39.95</price>  
  </book>  
</bookstore>
```

The following examples show how to access the various pieces of information within Tulip.

An extractor of:

```
/bookstore/book[1]/title
```

returns:

```
<title lang="en">Everyday Italian</title>
```

Note that arrays in XML are "1-indexed", meaning that the first element is in the "1" position, as opposed to JSON-query which is "0-indexed".

An extractor of:

```
/bookstore/book[1]/title/text()
```

returns:

```
Everyday Italian
```

Note that the `/text()` function is used to extract the text value contained within the selected node.

An extractor of:

```
/bookstore/book[@category="children"][1]/title/text()
```

returns:

```
Harry Potter
```

Note that the selector has allowed us to search within the properties of a node.

These examples can be directly used in Tulip as shown below:

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Working%20with%20SOAP%20and%20XML%20APIs_229776239.png)

### A SOAP API Example

Now let's examine a more complex case with namespaces, a typical feature of SOAP APIs.

```
<soap:Envelope  
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
>  
  <soap:Body>  
    <ns1:getInfoResponse xmlns:ns1="http://mes.myexample.com">  
      <ns1:out>  
        <errorCode xmlns="http://getInfo.mes.myexample.com">  
          0  
        </errorCode>  
        <errorMessage xmlns="http://getInfo.mes.myexample.com">  
          info retrieved successfully  
        </errorMessage>  
        <unitInfos xmlns="http://getInfo.mes.myexample.com">  
          <Info>  
            <currentOperation>My Operation</currentOperation>  
            <nextOperation>None</nextOperation>  
            <partName>1234567-890</partName>  
            <partRevision>B</partRevision>  
            <previousOperation xsi:nil="true"/>  
            <properties>  
              <Property>  
                <propertyName>PartNumber</propertyName>  
                <propertyValue>1234567-890</propertyValue>  
              </Property>  
              <Property>  
                <propertyName>PartRevision</propertyName>  
                <propertyValue>B</propertyValue>  
              </Property>  
              <Property>  
                <propertyName>PartDescription</propertyName>  
                <propertyValue>My example part</propertyValue>  
              </Property>  
            </properties>  
            <queueName xsi:nil="true"/>  
            <state>Normal</state>  
          </Info>  
        </unitInfos>  
      </ns1:out>  
    </ns1:getInfoResponse>  
  </soap:Body>  
</soap:Envelope>
```

This response uses XML Namespaces, which add complexity. For most cases, a global search using the `//*` and `.//*` operators makes extraction very simple.

An extractor of:

```
//*[local-name()="propertyName"][1]/text()
```

returns:

```
PartNumber
```

Note that arrays in XML are "1-indexed", meaning that the first element is in the "1" position, as opposed to json-query which is "0-indexed".

An extractor of:

```
//*[local-name()="Property"]
```

returns:

```
<Property xmlns="http://getInfo.mes.myexample.com">  
  <propertyName>PartNumber</propertyName>  
  <propertyValue>1234567-890</propertyValue>  
</Property>  
<Property xmlns="http://getInfo.mes.myexample.com">  
  <propertyName>PartRevision</propertyName>  
  <propertyValue>B</propertyValue>  
</Property>  
<Property xmlns="http://getInfo.mes.myexample.com">  
  <propertyName>PartDescription</propertyName>  
  <propertyValue>My example part</propertyValue>  
</Property>
```

Note here that the namespaces are "brought down" into this result. And therefore a sub-query would still search the global namespace.

To extract an Array of Objects, use the global search shown in the previous example to extract the array, and then a local search extractor of:

```
.//*[local-name()="propertyName"]/text()
```

to retrieve an array of objects of the form:

```
[  
  {  
    "Name": "PartNumber"  
    "Value": "1234567-890"  
  },  
  {  
    "Name": "PartRevision"  
    "Value": "B"  
  },  
  {  
    "Name": "PartDescription"  
    "Value": "My example part"  
  }  
]
```

These examples are shown in the Tulip Connectors Interface below:

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Working%20with%20SOAP%20and%20XML%20APIs_229781522.png)

---

Did you find what you were looking for?

You can also head to [community.tulip.co](https://community.tulip.co/?utm_source=intercom&amp;utm_medium=article-link&amp;utm_campaign=all) to post your question or see if others have faced a similar question!

**Connector Function**

**Connector Functions** are individual operations to interact with an HTTP or SQL Datasources. Connector Functions can have inputs and outputs, and can be called from: Triggers, Functions, Automations, and AI Agents.

Once pulled, data can be used throughout your applications.

**JSON**

**JSON (JavaScript Object Notation)** is a light-weight, text-based data format that is used to store and transfer data.

**Array**

**Arrays**are a Tulip Datatype. Arrays are a list of other variables. Every element in an array must be the same type.

Arrays are very useful when managing multiple values that represent the same information.

*ex. The measurements of 10 quality checks can be stored in an Array of Numbers, as opposed to 10 Number variables.*

**Object**

**Objects**are a Tulip Datatype. Objects represent an arbitrary grouping of attributes. Leveraging objects can simplify the process of working with complex data architectures. Often **Connector** **Functions** will return **Arrays** of **Objects**

*ex. My car object has 5 attributes, Color, Make, Model, # of wheels, # of seats.*

**Connectors**

**Connectors** enable real-time connectivity between your Tulip solution and a transactional system (e.g. an ERP). The output of a Connector Function can be used in Tulip Apps, Automations, and Functions.

- **HTTP Connectors** utilize HTTP API endpoints.
- **SQL Connectors** can enable connectivity with certain SQL databases.
- **MQTT Connectors** can connect to MQTT brokers for machine monitoring.

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/connector.gif)
