我想在PHP中爲Zend框架製作web服務控制器。我使用的是非WSDL模式(儘管我想如果它歸結爲它,我可以構建一個WSDL文件)。Zend SOAP服務器,非wsdl模式:位置和URI是什麼
class WebserviceController extends Zend_Controller_Action
{
public function soapAction()
{
$this->getHelper('viewRenderer')->setNoRender(true);
$soap_options = array('uri'=>$_SERVER['DOCUMENT_ROOT'] . 'webservice/soap/');
echo $soap_options;
$server = new Zend_Soap_Server(null, $soap_options);
$server->setClass('WebserviceAPI');
$server->handle();
}
}
WebserviceAPI是一個普通的老對象:
class WebserviceAPI
{
public function returnblah($one, $two)
{
return $one . ", " . $two . ": blah!";
}
}
我試圖測試只是爲了看看我是否可以把它連接:
$options = array('login' => '***',
'password' => '********',
'location' => 'https://localhost:8888/webservice/soap',
'uri' => 'https://localhost:8888/',
'trace' => 1);
$soap = new SoapClient(null, $options);
echo $soap->returnblah("a-one", "a-two");
它不連接。事實上,我不確定當Zend SOAP服務器以非WSDL模式構建時,Zend SOAP服務器的正確位置和uri應該是什麼。文檔不清楚如何連接到這種方式構建的Zend SOAP服務器。
ETA:我已經包含登錄名和密碼,以防身份驗證是它沒有連接的原因(儘管我懷疑它甚至沒有那麼遠)。
ETA2:這是實際的錯誤信息:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /Users/sabrina/Documents/testws2.php:28
,其中第28行是$ soap-實際通話> returnblah()。 (我在這裏發佈的代碼省略了很多垃圾,我已經在嘗試解決這個問題時發表了評論)
我開始懷疑我的實際連接問題可能是SOAP客戶端試圖通過https請求發送http,所以我正在努力解決這個問題,但是如果我使用正確的位置和uri參數,它仍然會有所幫助。
在此先感謝!
'位置'是應用程序的根目錄還是SOAP Web服務的特定URL? –
另外,你(或任何人)是否知道這個教程?我能找到的所有東西都是WSDL而不是非WSDL,而HTTP則是HTTPS。如果我必須我可以創建一個WSDL,但它不會解決我的HTTPS問題。 –
位置應該是你在你的web服務器上配置你的php應用程序的URL – Thierry