How To send a request to an external webservice using SurveyToGo

Overview

SurveyToGo allows you to send an asynchronous web service request directly from your survey scripts.

The SurveyToGo WebService functions:

The SurveyToGo user logic has two asynchronous functions dedicated for sending a request to a webservice:

1. Post request: string WebServicePost(string inUrl, string inData)

inUrl: The URL to send the post request to.

inData: The Data to post.

2. Get request:  string WebServiceGet(string inUrl)

inUrl: The URL to send the get request to.

Getting the webservice response:

Since the functions are asynchronous you will no get the response from the server immediately when calling the function.

In order to get the response from the webservice you will have to add the OnWebServiceResult overload to the surveys advanced script.

In Addition the SurveyToGo user logic has a function to parse the response from the WebServicePost/ WebServiceGet functions into an object, assuming that the answer from the webservice is in a legal Json format:

Object ParseJson(string JsonString);

 

An example of an overload to the OnWebServiceResult callback with a call to the ParseJson function which will set the response value to a global variable:

function OnWebServiceResult(inTicket, inOriginalUrl, inXMLResult, inIsError, inHttpStatus, inContentType)
{
Vars["response"] = ParseJson(inXMLResult);
}

 

 

That’s it!

Visit us at:  http://www.dooblo.net

 

 

Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.