Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smarty Soap Plugin (PHP)
<?php
/**
* Smarty {soap} plugin
*
* Type: function<br>
* Name: soap<br>
* Purpose: post http data and display results from soap webservice
* Params: url, post(true/false - passes along orig params), assign,
* Usage: {soap assign=soapResponse
* endpoint=http://www.site.com/search.soap
* call=resource..search
* var=(string)Text <- Format for setting
params
* debug=true|false }
*/
function smarty_function_soap($params, &$smarty)
{
global $_REQUEST;
if(empty($params['endpoint']) || empty($params['assign']) ||
empty($params['call'])) return false;
// use global include path for nusoap
require_once "includes/class/nusoap/nusoap.php";
// set params
$skip = array('endpoint', 'assign', 'call');
$soapParam=array();
foreach($params as $key=>$param) {
if(!in_array($key, $skip)) {
if
(preg_match('/\\((string|int|integer|bool|boolean|float|decimal|date)\\)(.+)/',
$param, $rs)) {
array_push($soapParam, new soapval($key,
"xsd:{$rs[1]}", "{$rs[2]}"));
}
}
}
// send request
$client = new soapclientw($params['endpoint']);
$response = $client->call($params['call'], $soapParam);
if(!empty($params['debug'])) {
echo "<pre>";
print_r($response);
print_r($client);
echo "</pre>";
}
$smarty->assign($params['assign'], $response);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.