note 98021 modified in class.soapserver by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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();
}

?>

--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 My_Soap_LiteralDocumentProxy {
	public function __call($methodName, $args) {
		$soapClass = new My_Soap();
		$result = call_user_func(array($soapClass, $methodName),  $args);
		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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.