# HTTP services

## Introduction

The HTTP Service Editor allows you to create simple REST services. The idea is that a form can call a service, typically passing XML back and forth.

To create a new HTTP service, click the Add icon under "HTTP Services". The HTTP Service Editor opens.

The following screenshot shows an example of filled-out service:

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-ef1793a394e00f89b30816ea1089d391a70a06fa%2Fservice-definition.png?alt=media" alt="Definition tab" width="561"><figcaption><p>Definition tab</p></figcaption></figure>

## Service definition

### Basic settings

The "Definition" tab allows you to set the basic service parameters:

* **Service Name**
  * This is the name of the service, as seen by Form Builder. Must start with a letter, and may not contain spaces.
  * \[SINCE Orbeon Forms 2020.1] The service can be renamed, and actions that use the service are automatically updated.
* **Resource URL**
  * `HTTP` or `HTTPS` URL to which the service must be called.
  * The value is an XPath Value Template, which means that the URL can be dynamic. For example, with Orbeon Forms 2018.1's `fr:control-string-value()` function:

    ```xpath
    https://example.org/{fr:control-string-value('control-1')}
    ```
  * [\[SINCE Orbeon Forms 2024.1\]](https://doc.orbeon.com/release-notes/orbeon-forms-2024.1) The resource URL can contain variable references to refer to the values of form controls (e.g. `$control-1`).
* **Method**
  * The HTTP method to use: `GET`, `POST`, `PUT` or `DELETE`.
* **Request Body**
  * This applies to the `POST` and `PUT` methods.
  * The XML document to send to the service. When using the "HTML Form" serialization, this is converted to name/value pairs.

### Serializations

#### Basics

Serializations apply to the `POST` and `PUT` methods only.

#### XML serialization

With the "XML" serialization, the XML data is passed using the [external data format](https://doc.orbeon.com/form-runner/api/data-formats/form-data).

On the wire, this serialization uses the `application/xml` content type.

#### HTML Form serialization

With the "HTML Form" serialization, leaf XML elements in the XML request body are converted to name/value pairs.

On the wire, this serialization uses the `application/x-www-form-urlencoded` encoding, like for standard web forms.

### URL parameters

\[SINCE Orbeon Forms 2016.1]

* This applies to the `GET` and `DELETE` methods.
* You can add as many URL parameters as needed.
* A non-blank URL parameter specifies a default value for the parameter.
* An action can set the value of a parameter.

Here is [how to set URL parameters from an action](https://doc.orbeon.com/form-builder/advanced/actions#passing-url-parameters-to-get-and-delete-methods).

### HTTP headers

\[SINCE Orbeon Forms 2026.1]

The HTTP headers section allows you to specify custom HTTP headers to send with the service request, similar to how URL parameters work.

* You can add as many HTTP headers as needed using the "+" button.
* A non-blank header value specifies a default value for the header.
* An action can set the value of a header.

Here is [how to set HTTP headers from an action](https://doc.orbeon.com/form-builder/advanced/actions#setting-http-headers).

### JSON support

\[SINCE Orbeon Forms 2016.1]

A JSON *response* from a service is processed and converted to an XML document following the XForms 2.0 scheme (see [JSON support](https://doc.orbeon.com/xforms/submission/submission-json)).

See [#2480](https://github.com/orbeon/orbeon-forms/issues/2480) for details about sending JSON to services.

### URL Parameters before Orbeon Forms 2016.1

Prior to Orbeon Forms 2016.1, a "request body" is mandatory for the `GET` and `DELETE` methods. The body is not sent to the service, but instead is used to configure request parameters.

The content of the "Request Body" form has to be a well-formed XML document. The name of the root element doesn't matter, but usually `params`or `request` is used. Each child element defines a parameter as shown in the following example:

```xml
<params>
    <userId>1</userId>
    <userName>test</userName>
</params>
```

Here Orbeon invokes the URL:

```
$<Resource URL>?userId=1&userName=test
```

where `$<Resoure URL>` is the content of the input field "Resource URL".

Make sure to select `HTML Form` in the `Serialization` dropdown, otherwise the URL parameters are not appended to the request URL.

## Advanced parameters

The "Advanced" tab allows you to set advanced service parameters:

* **Service Response has Binary Content**
  * \[SINCE Orbeon Forms 2020.1]
  * Check this if you know that the service returns binary content, such as an image. This is necessary if the [`<fr:control-setattachment>`](https://doc.orbeon.com/form-builder/advanced/actions-syntax#setting-the-value-of-an-attachment-control) action makes use of the response.
* **HTTP Authentication**
  * Whether to use HTTP authentication.
  * **Username:** Username to use.
  * **Password:** Password to use.
* **SOAP Service**
  * Whether this is a SOAP service
* **SOAP Action**
  * If selected, the value of the `SOAPAction` header.

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-e3fcd92f5084e89a7bd3b644e3cdf62a2d5e4099%2Fservice-definition-advanced.png?alt=media" alt="Advanced tab" width="562"><figcaption><p>Advanced tab</p></figcaption></figure>

## Testing a service

### Basics

The "Test" button allows you to test the service. Before doing this, you have to set data in the request body for a `POST` or `PUT` request, or you might want to set URL parameters for a `GET` or `DELETE`. Form Builder executes the service, and then provides information about the response returned, including:

* Whether an error occurred (green or red highlight)
* URL called
* Response status code
* Response headers
* Response body

This helps you troubleshoot the service call.

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-19d9031ea8616daafd206b1aca220bdf37630bc4%2Fservice-definition-test.png?alt=media" alt="Test Results tab with response headers" width="562"><figcaption><p>Test Results tab with response headers</p></figcaption></figure>

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-d9617881848a23389f292ed043e64092f82f88eb%2Fservice-definition-test-original-response-body.png?alt=media" alt="Test Results tab with response body" width="562"><figcaption><p>Test Results tab with response body</p></figcaption></figure>

### XML view of JSON responses

\[SINCE Orbeon Forms 2019.1]

When the service response is in JSON format, you can view the JSON response *translated into XML* following [XForms 2.0](https://www.w3.org/community/xformsusers/wiki/XForms_2.0#External_JSON_values).

This is useful when you want to use XPath expressions to access a JSON response, for example with [datasets](https://doc.orbeon.com/form-runner/features/datasets) or [item choices](https://doc.orbeon.com/form-builder/advanced/actions#setting-the-choices-of-a-selection-control).

See also [JSON support](https://doc.orbeon.com/xforms/submission/submission-json).

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-655b2e8f87a673f5b7f92887603a9a33c782189a%2Fservice-definition-test-xml-response-body.png?alt=media" alt="Test Results tab with XML response body" width="562"><figcaption><p>Test Results tab with XML response body</p></figcaption></figure>

## Saving the service

Once your service is defined, the "Save" buttons saves it to the form. You can come back to it and modify it later by clicking on the "Edit" icon next to the service name. You can also delete the service using the trashcan icon.

## Deleting a service

You can delete a saved service using the "Remove" button.

\[SINCE Orbeon Forms 2020.1]

Orbeon Forms warns you if there are existing actions that refer to the service.

## See also

* Blog post: [Making sense of Form Runner Actions](https://www.orbeon.com/2024/09/making-sense-form-runner-actions)
* [Simple Actions](https://doc.orbeon.com/form-builder/advanced/services-and-actions/actions)
* [Database services](https://doc.orbeon.com/form-builder/advanced/services-and-actions/database-services)
* [Synchronizing repeated content](https://doc.orbeon.com/form-builder/advanced/services-and-actions/synchronize-repeated-content)
* [Datasets](https://doc.orbeon.com/form-runner/features/datasets)
* [JSON support](https://doc.orbeon.com/xforms/submission/submission-json)


---

# 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://doc.orbeon.com/form-builder/advanced/services-and-actions/http-services.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.
