Example Web Service Interface
In the following example, the Data Connector applet connects to the web service at http://example.com/WebServiceExample/. The Web Service interface definition consists of two parts: Request and Response.
Request
The first element in the request object is Url. The Data Connector applet identifies the web service to connect to in the Url element. The method the Data Connector applet uses to connect to the web service is a POST method.
The Data Connector applet sends two headers:
- The first header has a key of Content-Type. The Content-Type header identifies the type of the content in the Interaction Definition field. In this example, the content type is XML.
- The second header has a key of Password. The Password header contains the password that the Data Connector must use to access the web service. The password is contained within a custom configuration setting, WebServicePassword. This custom configuration setting is encrypted and stored by Vonage Contact Center.
The Data Connector applet sends a value in the orderId element within the Body element. The Data Connector obtains the order ID value from an IVR slot, IVRSlot|OrderId. The caller provided the order ID to an IVR applet earlier in the call.
Response
The Type element in the response identifies the language of the response. In this example, the response is in XML.
The ResponseCodeDestination defines the Data Source that the Data Connector applet must store the response code in. The response code is a standard HTTP response code.
The Data Connector applet locates and stores two values from the web service response object:
- /name. The Data Connector applet stores the name value in the response object in a Data Source called ExampleCo|CustomerName. The value is of a String data type.
- /despatch. The Data Connector applet stores the despatch value in the response object in a Data Source called ExampleCo|DespatchDate. The value is of a String data type.
<ApiInteraction> <Request> <Url>http://example.com/WebServiceExample/</Url> <Method>POST</Method> <Headers> <Header> <Key>Content-Type</Key> <Value>application/xml</Value> </Header> <Header> <Key>Password</Key> <Value>#(WebServicePassword)</Value> </Header> </Headers> <Body><![CDATA[<?xml version='1.0' encoding='utf-8' ?><orderId>$(IVRSlot|OrderID)</orderId>]]></Body> </Request> <Response> <Type>XML</Type> <ResponseCodeDestination>WebService|HttpResponseCode</ResponseCodeDestination> <Fields> <Field> <Locator>/name</Locator> <Destination>ExampleCo|CustomerName</Destination> <DataType>String</DataType> </Field> <Field> <Locator>/despatch</Locator> <Destination>ExampleCo|DespatchDate</Destination> <DataType>String</DataType> </Field> </Fields> </Response> </ApiInteraction>
For general assistance, please contact Customer Support.
For help using this documentation, please send an email to docs_feedback@vonage.com. We're happy to hear from you. Your contribution helps everyone at Vonage! Please include the name of the page in your email.