我想在解析SOAP文件的PHP中獲得一個有效的示例。基本SOAP/PHP示例
我以下是一個示例:http://www.php.net/manual/en/soapclient.dorequest.php。 它不需要特別使用這個腳本(下面複製),但是爲了學習的目的,它應該很容易理解。我正在使用這個URL(只是一個隨機鏈接,我谷歌搜索):https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl,我試圖將它插入到'位置'和'uri'附近的底部,但在這兩種情況都沒有奏效。
本質上,我正在尋找一個簡單的腳本來學習解析SOAP文件的目的。
<?php
function Add($x,$y) {
return $x+$y;
}
class LocalSoapClient extends SoapClient {
function __construct($wsdl, $options) {
parent::__construct($wsdl, $options);
$this->server = new SoapServer($wsdl, $options);
$this->server->addFunction('Add');
}
function __doRequest($request, $location, $action, $version, $one_way = 0) {
ob_start();
$this->server->handle($request);
$response = ob_get_contents();
ob_end_clean();
return $response;
}
}
$x = new LocalSoapClient(NULL,array('location'=>'test://',
'uri'=>'http://testuri.org'));
var_dump($x->Add(3,4));
?>
謝謝。我實際上遇到了一些麻煩,找到一個很好的教程。也許你可以推薦一個? –
添加了答案的幾個鏈接。 – xmedeko
感謝這些鏈接xmedeko。 –