note 98021 modified in class.soapserver by danbrown
| From: | danbrown@php.net | Date: | Fri, 21 May 2010 14:16:03 +0000 |
| Subject: | note 98021 modified in class.soapserver by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169496@lists.php.net to get a copy of this message | ||
SoapServer does not support WSDL with literal/document. I have a class:
<?php
class My_Soap {
/**
* Returns Hello World.
*
* @param string $world
* @return string
*/
public function getInterAdmins($world) {
return 'hello' . $world;
}
}
?>
To fix this I had to create proxy class:
<?php
class My_Soap_LiteralDocumentProxy {
public function __call($methodName, $args) {
$soapClass = new My_Soap();
$result = call_user_func_array(array($soapClass, $methodName), $args[0]);
return array($methodName . 'Result' => $result);
}
}
?>
Now make sure that the WSDL is created using My_Soap. And that the Server is created using
My_Soap_LiteralDocumentProxy:
<?php
if (isset($_GET['wsdl'])) {
$wsdl = new Zend_Soap_AutoDiscover(); // It generates the WSDL
$wsdl->setOperationBodyStyle(array(
'use' => 'literal'
));
$wsdl->setBindingStyle(array(
'style' => 'document'
));
$wsdl->setClass('My_Soap');
$wsdl->handle();
} else {
$server = new Zend_Soap_Server('http://localhost/something/webservice.php?wsdl');
$server->setClass('My_Soap_LiteralDocumentProxy');
$server->handle();
}
?>
--was--
SoapServer does not support WSDL with literal/document. I have a class:
<?php
class My_Soap {
/**
* Returns Hello World.
*
* @param string $world
* @return string
*/
public function getInterAdmins($world) {
return 'hello' . $world;
}
}
?>
To fix this I had to create proxy class:
<?php
class Jp7_InterAdmin_Soap_LiteralDocumentProxy {
public function __call($methodName, $args) {
$soapClass = new Jp7_InterAdmin_Soap();
$result = call_user_func_array(array($soapClass, $methodName), $args[0]);
return array($methodName . 'Result' => $result);
}
}
?>
Now make sure that the WSDL is created using My_Soap. And that the Server is created using
My_Soap_LiteralDocumentProxy:
<?php
if (isset($_GET['wsdl'])) {
$wsdl = new Zend_Soap_AutoDiscover(); // It generates the WSDL
$wsdl->setOperationBodyStyle(array(
'use' => 'literal'
));
$wsdl->setBindingStyle(array(
'style' => 'document'
));
$wsdl->setClass('My_Soap');
$wsdl->handle();
} else {
$server = new Zend_Soap_Server('http://localhost/something/webservice.php?wsdl');
$server->setClass('My_Soap_LiteralDocumentProxy');
$server->handle();
}
?>
http://php.net/manual/en/class.soapserver.php