tony-landis (owner)

Revisions

gist: 31456 Download_button fork
public
Description:
Smarty Soap Plugin (PHP)
Public Clone URL: git://gist.github.com/31456.git
Embed All Files: show embed
smarty.function.soap.php #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?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);
}
?>