Commit 42ddbc47 authored by killianebel's avatar killianebel

[FIX] Improved webservice client to process correctly inputs which are complex types

parent 1ad9dac0
......@@ -261,7 +261,7 @@ class OIntegrate_Response
function getTemplates( $supportedPairs = null ) // {{{
{
if( ! isset( $this->data['_template'] ) || ! is_array( $this->data['_template'] ) )
if( !is_array( $this->data ) || ! isset( $this->data['_template'] ) || ! is_array( $this->data['_template'] ) )
return array();
$templates = array();
......
......@@ -27,9 +27,24 @@ class Tiki_Soap
}
$client = new Zend_Soap_Client( $wsdl, $options );
$soap_params = array();
foreach ($params as $param_name => $param_value) {
preg_match('/^(.*)\:(.*)$/', $param_name, $matches);
if (count($matches) == 3) {
if (!isset($soap_params[$matches[1]])) {
$soap_params[$matches[1]] = array();
}
$soap_params[$matches[1]][$matches[2]] = $param_value;
} else {
$soap_params[$param_name] = $param_value;
}
}
try {
$result = call_user_func_array(array($client, $operation), $params);
$result = call_user_func_array(array($client, $operation), $soap_params);
} catch (SoapFault $e) {
trigger_error($e->getMessage());
......@@ -38,7 +53,10 @@ class Tiki_Soap
if (is_object($result)) {
$result_name = $operation . 'Result';
return $result->$result_name;
if (isset($result->$result_name)) {
return $result->$result_name;
}
}
return $result;
......
......@@ -26,7 +26,7 @@ class Tiki_Wsdl
$context = null;
if ( $prefs['use_proxy'] == 'y' ) {
if ( $prefs['use_proxy'] == 'y' && !strpos($wsdlUri, 'localhost') ) {
// Use proxy
$context = stream_context_create(array(
'http' => array(
......@@ -58,7 +58,19 @@ class Tiki_Wsdl
if (isset($data['input']['parts'])) {
foreach ($data['input']['parts'] as $parameter => $type) {
$parameters[] = $parameter;
preg_match('/^(.*)\:(.*)\^?$/', $type, $matches);
if (count($matches) == 3) {
$typeDef = $wsdl->getTypeDef($matches[2], $matches[1]);
if (isset($typeDef['elements'])) {
foreach ($typeDef['elements'] as $element) {
$parameters[] = $typeDef['name'] . ':' . $element['name'];
}
}
} else {
$parameters[] = $parameter;
}
}
}
......
......@@ -147,7 +147,7 @@ class Tiki_Webservice
if ( !empty($this->operation) ) {
$options = array( 'encoding' => 'UTF-8' );
if ( $prefs['use_proxy'] == 'y' ) {
if ( $prefs['use_proxy'] == 'y' && !strpos($built, 'localhost') ) {
$options['proxy_host'] = $prefs['proxy_host'];
$options['proxy_port'] = $prefs['proxy_port'];
}
......
......@@ -9,6 +9,24 @@ require_once 'tiki-setup.php';
$access->check_feature('feature_webservices');
/**
* Example of complex type
*/
class Tiki_ComplexType
{
/**
* Param 1
* @var string
*/
var $param1;
/**
* Param 2
* @var string
*/
var $param2;
}
/**
* Write your SOAP webservices as methods of this class, it will be automagically
* added to the WSDL file.
......@@ -30,6 +48,17 @@ class Tiki_WebServices
{
return 'test1 ' . $param1 . ' test2 ' . $param2 . ' test3 ' . $param3;
}
/**
* Displays the Tiki_ComplexType data.
*
* @param Tiki_ComplexType $complex_param
* @return string
*/
function test_complex(Tiki_ComplexType $complex_param)
{
return $complex_param->param1 . ' =====> ' . $complex_param->param2;
}
}
require_once 'lib/core/Zend/Soap/Server.php';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment