Page 1 of 1

How to call SOAP API using VXML?

Posted: Thu Apr 14, 2016 4:46 pm
by vikas
Hi Plum

I have a requirement where I need to call a SOAP API and fetch few response fields.

Going through other Posts I see that Plum recommends to use <data> tag.
But how do we send request parameters & set request header for SOAP API call.

Is there any example implementation that I can refer to?

Re: How to call SOAP API using VXML?

Posted: Fri Apr 15, 2016 8:01 am
by support
Hi Vikas,

Headers are supported but there is no SOAP method in vxml.

Regards,
Plum Support

Re: How to call SOAP API using VXML?

Posted: Fri Apr 15, 2016 11:35 am
by vikas
Do you mean that I cannot call SOAP API using <data> tag?
If not what are my options? Let me know. Thanks.

Re: How to call SOAP API using VXML?

Posted: Fri Apr 15, 2016 6:25 pm
by support
Hi Vikas,

That is correct. It is not possible to use a SOAP API using the <data> tag.

We recommend that you use some web scripting language to connect to your SOAP API and generate a valid VXML response based on the result. Here is an simple example in PHP:

start.vxml:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
  <var name="account_number"/>
  <form>
    <field name="account" type="digits">
      <prompt>
        Please enter your account number.
      </prompt>
      <filled>
        <assign name="account_number" expr="account"/>
        <submit next="webservice.php" method="post" namelist="account_number" />
      </filled>
    </field>
  </form>
</vxml>
webservice.php:

Code: Select all

<?php
  header("Content-type: text/xml");
  echo("<?xml version=\"1.0\"?>\n");
  // get the variables posted to this script
  $account_number = $_POST['account_number'];

  // connect to SOAP webservice
  $soap_url = "http://someurl.to/your/wsdl";
  $client = new SoapClient($soap_url);

  $params = array(
    'AccountNum' => $account_number
  );

  $response = $client->validate($params);  //TRUE or FALSE
?>

<vxml version="2.0">
  <form>
    <block>
      <prompt>
<? if ($response): ?>
        Your account is valid.
<? else: ?>
        Your accound is invalid.
<? endif; ?>
      </prompt>
      <exit/>
    </block>
  </form>
</vxml>
Regards,
Plum Support