TryLearn More

Use SIP trunks, WebRTC & Apps

Slash your Phone Bill by 80%

Creating a phone support portal with 3CX VAD – Part 2


In the article Creating a phone support portal with 3CX VAD – Part 1, we have shown how to how to create the application callflow to validate whether a customer has a support contract, and then transfer the call to the appropriate department. We have left the validation using different data sources for subsequent articles.

In this article we will show how to perform the validation using a Web Service.

How to invoke the Web Service

The VAD includes the “Web Services Interaction” component out of the box, which allows invoking simple web services. The following article will helpful you to understand how to use the Web Service component.

If the web service is designed to return a single value, then we can use this component. But in case the response is a complex XML, then it would be better to create a DLL and invoke the web service from there, so the result can be analyzed programmatically.

Assuming that the web service returns a single value, we’ll use this component to invoke it. To do this, open the user component created in the previous article to perform the customer validation (“ValidateData”), drag a “Web Services Interaction” component from the toolbox and drop it into the design surface. Rename the component to “validateDataWS” and configure the URL, the web service name and the parameters as shown in the following figure:


Then we need to set the appropriate value to the output property “ValidationResult”, depending on the web service result. Assuming that the web service returns the value 1 when the validation is successful, and 0 when it’s not, we can use a “Variable Assignment” component in order to assign the value resulting from the following expression to the variable “callflow$.ValidationResult”:


PhoneSupportPortal_02_02The resulting diagram will look like this

Invoking the Web Service from a DLL

In case the web service returns a complex XML, we can invoke it from inside a DLL. This requires programming knowledge.

To do this, open Visual Studio and create a new Class Library project (File > New > Project > Visual C# > Windows > Class Library). In this example we’ll make the coding in C# language, but it’s possible to use any other .NET framework language. Let’s name the project “ComplexWebService”.

Once the project has been created, rename the main class from “Class1” to “WebServiceClient”, and write the following code:

using System;
using System.Text;
using System.Net;
using System.IO;
using System.Xml;

namespace ComplexWebService
  public class WebServiceClient
    public bool ValidateCustomer(string id, string pin)
      HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(
      webRequest.Method = "POST";
      webRequest.Timeout = 30000;

      UTF8Encoding encoding = new UTF8Encoding();
      byte[] byteArray = encoding.GetBytes(String.Format("id={0}&pin={1}", id, pin));

      webRequest.ContentType = "application/x-www-form-urlencoded";
      webRequest.ContentLength = byteArray.Length;

      using (Stream requestStream = webRequest.GetRequestStream())
        requestStream.Write(byteArray, 0, byteArray.Length);

      using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse())
        using (StreamReader streamReader = new StreamReader(
          XmlDocument xmlDocument = new XmlDocument();

          XmlNodeList hasSupport = xmlDocument.GetElementsByTagName("Authenticated");
          return Convert.ToBoolean(hasSupport[0].InnerText);

Build the project and copy the generated DLL into the “Libraries” folder located into the VAD project folder. This DLL will be invoked from an “External Code Execution” component. To do this, add a new “External Code Execution” component to the design surface and configure it as follows:


Then we need to assign the result in the same way we did when using the “Web Services Interaction” component, but in this case the execution result is a boolean value, so it can be directly assigned to the output property. So we’ll use a “Variable Assignment” component to assign the value “callWebService.ReturnValue” to the variable “callflow$.ValidationResult”. The diagram will look like the following:



In this article we have shown how to invoke a web service to validate the data entered by the customer, either directly or through a DLL created with Visual Studio. The next articles in the series will show how to perform this validation through the following external data sources:

  • XML File
  • CSV Text File
  • Microsoft Excel Spreadsheet
  • SQL Server Database
  • Microsoft Access Database File
  • Another database via ODBC

The Third part of the series Creating a phone support portal with 3CX VAD – Part 3 shows how to perform the validation using XML and CSV text format.

By |May 11th, 2015|Comments Off on Creating a phone support portal with 3CX VAD – Part 2