Answer the question
In order to leave comments, you need to log in
How to make Soap Server in PHP so that it supports the ws-i standard?
Hello!
I have the following problem.
It was necessary on the portal to implement a connection between the portal and a program written in C #, we wrote a SOAP service using zend soap server and zend soap autodiscover. But as a result, C# does not understand the response from this service because it does not support the ws-i standard.
Maybe someone has already encountered this and found a solution to this problem?
SOAP server code:
if ( $wsdl !== null ) {
$autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$autodiscover->setOperationBodyStyle( array ('use'=>'literal', 'namespace'=>'http://' . $hostname . '/api2/' . (is_array($this -> key) ? $this -> key['key'] : $this -> key) . '?wsdl'));
$autodiscover->setBindingStyle(array('transport'=> 'http://schemas.xmlsoap.org/soap/http'));
$autodiscover -> setClass('Model_Soap');
}
elseif ($request -> isPost()) {
$server = new Zend_Soap_Server('http://' . $hostname . '/api2/' . (is_array($this -> key) ? $this -> key['key'] : $this -> key) . '?wsdl');
$server->setClass('Model_Soap');
$server -> handle();
}
Answer the question
In order to leave comments, you need to log in
I solved this problem by adding a special Proxy class to the model, which converts incoming and outgoing data to the server.
class Service_SoapProxy
{
protected $_service;
public function __construct()
{
$this->_service = new Model_Soap();
}
public function __call($name, $arguments)
{
$params = array();
if(count($arguments) > 0){
foreach($arguments[0] as $property=>$value){
$params[$property] = $value;
}
}
$result = call_user_func_array(array($this->_service, $name), $params);
return array("{$name}Result" => $result);
}
}
if ( $wsdl !== null ) {
$autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$autodiscover->setBindingStyle(array('style'=>'document'));
$autodiscover->setOperationBodyStyle(array('use' => 'literal'));
$autodiscover->setClass('Model_Soap');
$autodiscover->handle();
}
elseif ($request -> isPost()) {
// Request soap
if (! empty($this -> key)) {
$wsdl = 'http://' . $hostname . '/api2/' . (is_array($this -> key) ? $this -> key['key'] : $this -> key) . '?wsdl';
}
else
$wsdl = 'http://' . $hostname . '/api2/?wsdl';
$server = new Zend_Soap_Server($wsdl, array('cache_wsdl'=>false));
$modelSoap = new Service_SoapProxy();
$server->setObject($modelSoap);
$server->handle();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question