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

Retrieving Answer With SOAP

Questions and answers about Plum Survey

Moderators: admin, support

Post Reply
takeout
Posts: 4
Joined: Wed Jun 17, 2009 3:06 pm

Retrieving Answer With SOAP

Post by takeout »

Hey, I am simply trying to get the phone input as a variable in php. I set up SOAP and have the XML generated with no errors. The survey SHOULD ask you to input a number (which it does), then connect to the page, go to "plumEval", and then say whatever I return. Right now i don't even think it is connecting because I put a mail statement in the plumEval function, so if it goes into that function, it will email something to me. Nothing has been emailed. Here is the test php file.

Code: Select all

<?php
  /*************  
  * PLUM SURVEY SAMPLE WEBSERVICE  
  * This webservice demonstrates how to make a SOAP service for use with a  
  * 'SOAP webservice' question in a survey.  
  * (c) 2008 Plum Voice  
  *************/  
  $NAMESPACE = "http://survey.plumvoice.com";  
  $DEBUG = true;  
 
  include_once('WSDL_Gen.php');  
  $WS_DOC_CSS = "css/ws_doc.css";  
  $DESCRIPTION = "An example of a webservice that could be used by a \"SOAP webservice\" question in a survey.";  
  class SampleWebservice extends Services_Webservice 
  {
    function plumEval($question_texts, $answers) 
	{
		mail('test@myemail.com', 'test', 'TEST', 'From: test@example.com');//Just to test if it is even going into this function. It has not been.

		return $answers;//If I enter "1" on the keypad, I want the computer to say, "One"
    } 
     
   } 
	 
   $myService = new SampleWebservice($NAMESPACE, $DESCRIPTION, array('uri'=>$NAMESPACE, 'encoding'=>"1"));  
	 
   session_start(); 
   $myService->handle(); 
What is wrong? What should I have on my Surveys page for something simple like that.

Thanks.

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

confusion about IVR webservice question type

Post by support »

Could you provide us with a link to your WSDL? If you are in fact using the WSDL_Gen library we use, deleting the block comment before the plumEval function will destroy the WSDL autogeneration and it will not run at all.

Also, you may be confused about how the webservice question type for IVR operates. It will never speak anything back to the IVR survey taker; the string that is returned is only stored and possibly branched on if skip logic is created.

If you want answers to be spoken back to the user, you will need to use the subdialog question type for IVR. You will need to learn some basic VoiceXML to get the IVR subdialog type operating, so reviewing our VoiceXML tutorial will help.
Last edited by support on Thu Mar 04, 2010 4:52 pm, edited 3 times in total.

takeout
Posts: 4
Joined: Wed Jun 17, 2009 3:06 pm

Post by takeout »

Thanks, I deleted the block comment just for the purpose of posting it on the forum to take less space. In my code it does exist. I am basically trying to check if a given condition is true, if so, say "...", if not, say "...".

Here is my WSDL file.

http://menusanddeals.com/PhoneVerification.php?WSDL


Here is my whole file.

Code: Select all

<?php
  /*************  
  * PLUM SURVEY SAMPLE WEBSERVICE  
  * This webservice demonstrates how to make a SOAP service for use with a  
  * 'SOAP webservice' question in a survey.  
  * (c) 2008 Plum Voice  
  *************/  
  $NAMESPACE = "http://survey.plumvoice.com";  
  $DEBUG = true;  
 
  include_once('WSDL_Gen.php');  
  $WS_DOC_CSS = "css/ws_doc.css";  
  $DESCRIPTION = "An example of a webservice that could be used by a \"SOAP webservice\" question in a survey.";  

  class SampleWebservice extends Services_Webservice {  
 
  /** 
   * The WSDL that you use should specify only one function named "plumEval". 
   * This function will receive two arrays of strings: one with the  
   * text of each question, and the other with all the answers received  
   * on the current page. These arrays will be indexed in the same fashion,  
   * e.g., each array's elements will be ordered so that the questions  
   * correspond with the answers.  This function should return a string,  
   * which will be saved as the response for the question calling this  
   * webservice.  If there is a choice with skip logic that corresponds to  
   * this answer, it will be followed. ... 
   *  
   * This sample webservice returns "accepted" if any of the submitted answers  
   * were "yes", and "rejected" otherwise.  To demonstrate that session  
   * cookies can be set and checked, after the webservice has "accepted" once,  
   * it will return "accepted again" for every future call within the same  
   * survey where any of the submitted answers were "yes". 
   * 
   * @param string[] $question_texts 
   * @param string[] $answers 
   * @return string 
   **/ 
  function plumEval($question_texts, $answers) 
	{
		$to      = '#####';
		$subject = 'test';
		$message = 'TEST';
		$headers = 'From: test@example.com' . "\r\n" .
			'Reply-To: webmaster@example.com' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
		
		mail($to, $subject, $message, $headers);
		return "1";
    } 
     
   } 
	 
   $myService = new SampleWebservice($NAMESPACE, $DESCRIPTION, array('uri'=>$NAMESPACE, 'encoding'=>"1"));  
	 
   session_start(); 
   $myService->handle(); 
Last edited by takeout on Fri Jun 19, 2009 2:22 pm, edited 1 time in total.

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

IVR code to test your webservice

Post by support »

Thanks for posting the entirety of your IVR code.

It seems like accessing your webservice is returning an Internal Server Error. We aren't sure why, but it may have to do with the setup of your webhost. You may want to try removing the IVR code you inserted for emailing and seeing if it works by itself, it is possible that mail is not setup properly on your webhost.

We used the following IVR code to test your webservice (Plum IVR Survey runs a nearly equivalent procedure to access your webservice during a live IVR call). You can see the results for yourself by putting it in a separate PHP script and running it.

Code: Select all

<?php
$client = new SoapClient('http://menusanddeals.com/PhoneVerification.php?WSDL', array('trace'=>TRUE));
try {
  $question_texts = array('Question 1');
  $answers = array('Answer 1');
  var_dump($client->plumEval($question_texts, $answers));
  var_dump($client->__getLastResponse());
} catch (SoapFault $e) {
  echo $e->faultcode . ": " . $e->getMessage(); 
}
A SoapFault is being returned that indicates that at the HTTP layer you are returning an Internal Server Error (500).
Last edited by support on Thu Mar 04, 2010 4:53 pm, edited 4 times in total.

takeout
Posts: 4
Joined: Wed Jun 17, 2009 3:06 pm

Post by takeout »

I tried that email script separately on the same webhost before I put it in, it works fine. So it's not that. I tried putting that test script on my host so I can test it myself and try to get support from my webhost on the issue, however my webhost does not support SOAP.

That shouldn't make a difference for plum voice to connect though should it? Because the actual SOAP queries are on your server. So what should I do? If I do need SOAP on my host for it to work (not the test, the actual phone call), then I will try to get it on. Otherwise, I don't even know what to tell my host so they can try to fix the issue, because there is no way of them testing it.

Thanks

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

for IVR code to work, run PHP with SOAP extensions enabled

Post by support »

In order for either our sample IVR code or the test code I just gave you to work, you must be running PHP with the SOAP extensions enabled (PHP must have been configured with --enable-soap at compilation). You can verify what extensions have been installed by running:

Code: Select all

<?php
phpinfo();
and checking for --enable-soap in the "Configure Command" section and a "soap" section somewhere below that.

If your IVR webhost did not compile PHP with SOAP enabled, there are other ways of building a SOAP server in PHP, but as we do not use these libraries we will be limited in our ability to help you with them. SOAP queries, whether coming from our test script or our VXML platform, require a SOAP IVR server to be provided by you, so the above is a prerequisite to you building a SOAP IVR service in PHP for us or any other IVR webservice consumer.
Last edited by support on Thu Mar 04, 2010 4:55 pm, edited 2 times in total.

takeout
Posts: 4
Joined: Wed Jun 17, 2009 3:06 pm

Post by takeout »

Alright it is not enabled. I will see what I can do to try to get it on, maybe switch hosts if I have to. Thanks for your help!

Post Reply