We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

best way to call a CFML webservice

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

best way to call a CFML webservice

Post by sweetp123 »

I have been reading through the forum and am a little confused about how to go about calling a ColdFusion web service from one of my pages.

let's say my webservice is at:
http://www.mysite.com/components/mywebservice.cfc?wsdl

I want to pass in one variable (a PIN that the user has entered) and the function mywebservice returns a string containing the accountID or the user if it is valid and an empty string if it is not.

I know i need to call it as method POST because i am sending a variable but where is my return value (the string) going to be located? should i use submit, data or subdialog?

Thanks!

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Use data tag or subdialog call so control is returned to IVR

Post by support »

Hi,

You'll probably want to use either the IVR tag, <data>, or a subdialog call; this way, control is returned to the IVR at the appropriate place in the IVR call flow.

Here is an (untested, so caveat emptor) IVR example of doing this with a subdialog call:

<form id="callWebService">
<subdialog name="getAccountID" src="getAccountID.vxml" namelist="PIN" method="post"> <!-- PIN is declared and assign somewhere else -->
<filled>
<if cond="getAccountID.accountID == ''">
oh, no... we got an empty string
<else />
we didn't get any empty string... let's do something interesting
</if>
</filled>
</subdialog>
</form>

In getAccountID.vxml, you'll have some scripting (ColdFusion, PHP, ASP, whatver) that accepts the POSTed PIN variable and does something with it. At the end of this document, you'll need a simple form that returns one or more variables using the IVR tag, <return>, (below example is PHP):

<?php

$PIN = $_POST['PIN'];
$accountID = call_web_service($PIN);

?>

<vxml>
<form id="returnAccountID">
<block>
<var name="accountID" expr="'<?= $accountID ?>'" />
<return namelist="accountID" />
</block>
</form>
</vxml>


Hope this helps,

Plum Support
Last edited by support on Thu Feb 25, 2010 1:30 pm, edited 5 times in total.

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

ok thanks i'll try this once i get my application setup properly as i am just using the scratchpad for now.
where does the verifyPIN.vxml file reside? on my own server?
so it's not really calling a web service then - just a page that is posted to remotely?
and how will it be executed properly by my cold fusion server if the extension is vxml...???
sorry for all the questions - i'm new to this and just trying to get my head around it :oops:

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

sorry i meant the getaccountID.vxml file - where will it reside?

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR script

Post by support »

The getaccountID.vxml file will reside on your own IVR server. It doesn't have to have the .vxml extension. It could be .cfm or .php or .asp or whatever's necessary for your IVR application server to execute the IVR script.

As far as whether it's a web service -- by definition, any IVR script that accepts POST parameters from another script and responds with data, XML-formatted or not, is a web service. So a "page that is posted to remotely" is definitely a web-service since it responds to requests via HTTP with raw data in a format that can be parsed by the requesting IVR application.
Last edited by support on Tue Feb 23, 2010 3:18 pm, edited 2 times in total.

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

i got it working :D

for future reference for other coldfusion developers:
i finally realized why i was having so many problems - coldfusion adds a ton of whitespace to the beginning of pages mainly due to the Application.cfm page that is processed - so i used cfsilent tags around all of my code - including the Application file and also the cfprocessingdirective suppresswhitespace = yes as well as the cfsetting tag to enable cfoutput only.

the returned page was then recognized as a proper xml file...
thanks for your help - the last call log file pages made a huge difference in debugging the code

Post Reply