1
我正在生成一個WSDL,我需要更改響應中的函數名稱以匹配來自客戶端的名稱(我無法控制)。如何更改Zend Soap Server中的響應函數名稱?
這裏的WSDL響應我得到:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost:8000/soap/index.php?wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:fooFunctionResponse>
<return xsi:type="xsd:boolean">true</return>
</ns1:fooFunctionResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我需要行<ns1:fooFunctionResponse>
閱讀<ns1:fooFunctionAcknowledgement>
。
這裏是我的SOAP服務器:
if (isset($_GET['wsdl'])) {
ini_set('soap.wsdl_cache_enabled', 0);
$soapAutoDiscover = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence());
$soapAutoDiscover->setBindingStyle(array('style' => 'document'));
$soapAutoDiscover->setOperationBodyStyle(array('use' => 'literal'));
$soapAutoDiscover->setClass('SoapFunction');
$soapAutoDiscover->setUri(http://localhost:8000/soap/index.php);
$soapAutoDiscover->handle();
} else {
$soap = new \Zend\Soap\Server(null, array("soap_version" => SOAP_1_2, 'uri' => 'http://localhost:8000/soap/index.php?wsdl', 'classmap' => array('Identification', 'RemoteIdentification')));
$soap->setClass('SoapFunction');
$soap->handle();
}
我發現這行代碼在Zend框架(Autodiscover.php
線514),它看起來像它控制函數的命名:
$element = [
'name' => $functionName . 'Response',
'sequence' => $sequence
];
但改變它什麼都不做,父方法永遠不會被調用。我不知道如何解決這個問題,請幫助。
我發現,這行確實改變了函數名,但是我使用了SoapUI來測試我的API,並從我了SoapUI總是看到的Response
而不是無論我改變字符串。在Chrome中,我看到Acknowledgement
。
爲什麼SoapUI顯示不同的函數名?
我會這樣做,如果我確定包含'response()'的方法被調用。據我所知,該方法沒有被調用。 – f7n
我剛剛查過並看到該方法被調用,但SoapUI正在做一些奇怪的事情,請參閱我的編輯。 – f7n