Defining a web service interaction using XML to retrieve data from and send data to a Web Service
Overview
The Web Service interface in a Data Connector applet enables you to retrieve data from and send data to an external web service. You define the interaction by writing XML directly in the Interaction Definition field. To use a pre-built configuration instead, see Using a template to retrieve data from and send data to a Web Service.
When a Data Connector applet uses a Web Service interface, it is sometimes referred to as a Web Service Data Connector (WSDC).
For more information about the Data Connector applet, see Data Connector applet.
JavaScript Engine uses a dedicated experience
The Web Service Data Connector is no longer used to define JavaScript Engine Data Connectors. These have been moved to their own dedicated experience. For more information, see Using the Vonage Contact Center JavaScript Engine.
Defining a web service interaction
Create a Data Connector applet. For more information, see Creating an applet. A new Data Connector applet appears.
In the Interface section, select Web Service. The Action and Web Service Interaction sections appear.
In the Interface Failure list, select the applet to route the call to if the interface fails.
Interface failure vs. HTTP error status codes
An interface failure occurs when the Data Connector does not receive a response, for example, due to a timeout or a DNS lookup failure. This is different from receiving a response with an HTTP error status code.
In the Action section, select Call Web Service. The Web Service Interaction section appears. The Interaction Definition field contains the following template XML:
<ApiInteraction>
<Request>
<Url></Url>
<Method></Method>
<Headers>
<Header>
<Key></Key>
<Value></Value>
</Header>
</Headers>
<Body><![CDATA[ ]]></Body>
</Request>
<Response>
<Type></Type>
<ResponseCodeDestination></ResponseCodeDestination>
<Fields>
<Field>
<Locator></Locator>
<Destination></Destination>
<DataType></DataType>
</Field>
</Fields>
</Response>
</ApiInteraction>For a complete example of a configured web service interaction, see Example web service interface.
Define the request. Use the template XML as a basis and complete the following elements:
Request elements
XML element | Required or optional | Description | Example |
|---|---|---|---|
| Required | The address of the web service. Must include the protocol ( |
|
| Required | The HTTP method. Supported values: |
|
| Optional (required if you define one or more | All headers defined in this block are added as HTTP headers to the request.
To authenticate with basic access authentication, send Base64-encoded credentials in the |
|
| Optional (not supported for | The body of the request. To include XML or JSON content, wrap it in a CDATA section ( |
|
Header elements
Complete the following elements for each Header in the Headers block:
XML element | Required or optional | Description | Example |
|---|---|---|---|
| Optional (required if | A single HTTP header, consisting of a | N/A |
| Required for each | The name of the HTTP header. |
|
| Required for each | The value of the HTTP header. |
|
You can insert Data Source or custom configuration values as placeholders in the Url, Key, Value, and Body elements. For more information, see Using a Data Source value in a Web Service Interface request or Using a custom configuration value in a Web Service Interface request.
Define how to handle the response. Complete the following elements:
Response elements
XML element | Required or optional | Description | Example |
|---|---|---|---|
| Required | The expected response format. Supported values:
When |
|
| Required | The name of the Data Source in which to store the HTTP response code returned by the web service. Use this value in a subsequent applet, for example, a Data Router, to determine whether the interaction was successful. Any response code greater than 399 indicates a failure. For more information, see the List of HTTP status codes. |
|
| Optional (required if you define one or more | Define one | N/A |
Field elements
Complete the following elements for each Field in the Fields block:
XML element | Required or optional | Description | Example |
|---|---|---|---|
| Optional (required if | A single response value to store in a Data Source, consisting of a | N/A |
| Required for each | The location of the value in the response. For XML responses, use an XPath query. For JSON responses, use JSON dot notation. For more information, see Defining JSON locators. | XML: |
| Required for each | The name of the Data Source in which to store the returned value. |
|
| Required for each | The data type of the returned value. Must be one of: |
|
Test the interaction before saving. For more information, see Testing your web service interaction definition.
In the Successful Action list, select the applet to route the interaction to next.
Successful action and HTTP error codes
A successful action indicates that the web service returned a response. This includes responses with HTTP error status codes. To handle specific response codes, use the ResponseCodeDestination value in a subsequent Data Router applet.
Click Update to save the configuration. Any configuration errors appear at the top of the page. The applet is not saved until all errors are resolved.
After saving:
If the web service returns a response, the interaction routes to the Successful Action applet.
If the web service does not return a response, the interaction routes to the Interface Failure applet.
Interaction Definition field: highlighting and autocomplete
The Interaction Definition field includes built-in editing tools to speed up configuration. The following features are available:
The field provides XML and JSON syntax highlighting as you type.
A list of available XML tags appears when you type
<. PressCtrl+Spaceto trigger the list manually.Typing
<!inserts a CDATA wrapper.Matching XML tags, curly brackets, and square brackets are highlighted automatically.
Typing
$displays a list of available Data Sources. Typing#displays a list of available custom configuration keys.The field supports standard text-editing shortcuts:
Ctrl+A,Ctrl+C,Ctrl+X,Ctrl+V,Ctrl+Z,Ctrl+Y.Press
Ctrl+Jto navigate to the closing XML tag of an element.Press
Ctrl+Dto delete a line.
