運行與Zend的一個問題,因爲它拋出一個錯誤。我相信這是由於Zend在URL中的下劃線所致。Zend_XmlRpc_Client會強調在主機
我有一個Python客戶端,做同樣的基本功能,它按預期工作。
想知道如果有一個PHP
錯誤解決方法:
Fatal error: Uncaught exception 'Zend_Uri_Exception' with message 'Invalid URI supplied' in /usr/share/php/libzend-framework-php/Zend/Uri/Http.php:156
Stack trace:
#0 /usr/share/php/libzend-framework-php/Zend/Uri.php(143): Zend_Uri_Http->__construct('http', '//local_server_f...')
#1 /usr/share/php/libzend-framework-php/Zend/Http/Client.php(270): Zend_Uri::factory('http://local_ser...')
#2 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(266): Zend_Http_Client->setUri('http://local_ser...')
#3 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(361): Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request))
#4 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client/ServerProxy.php(93): Zend_XmlRpc_Client->call('system.multical...', Array)
#5 [internal function]: Zend_XmlRpc_Client_ServerProxy->__call('multicall', Array)
#6 /path/to/xmlrpc.client.php(21): Zend_XmlRpc_Client_ServerProxy->multicall(Array)
#7 {main}
thrown in /usr/share/php/libzend-framework-php/Zend/Uri/Http.php on line 156
PHP:
ini_set("include_path", "/usr/share/php/libzend-framework-php");
require_once('Zend/XmlRpc/Client.php');
$server = new Zend_XmlRpc_Client('http://local_server_foo/xmlrpc.server.php');
// Get the HTTP Client used by the XMLRPC client and Increase the HTTP timeout
$server->getHttpClient()->setConfig(array('timeout'=>30));
$client = $server->getProxy();
$request = array(
array(
'methodName' => 'system.listMethods',
'params' => array()
)
);
try {
$response = $client->system->multicall($request);
echo print_r($response,true);
} catch (Zend_XmlRpc_Client_HttpException $e) {
echo 'HTTP Exception: '."\n";
echo $e->getCode();
echo $e->getMessage();
} catch (Zend_XmlRpc_Client_FaultException $e) {
echo 'Fault Exception: '."\n";
echo $e->getCode();
echo $e->getMessage();
}
的Python(這工作):
#!/usr/bin/python
import xmlrpclib
servAddr = "http://local_server_foo/xmlrpc.server.php"
client = xmlrpclib.ServerProxy(servAddr)
print
methods = client.system.listMethods()
for m in methods:
print m + "\tHelp Documentation: " + client.system.methodHelp(m)
print
那裏沒有爭論,爲什麼我還沒有提出問題。我看到的唯一的一點是,驗證具有廣泛的驗證上面,然後在年底,標示爲最終的正則表達式「檢查對本地網絡名稱輸入模式;最後的機會,通過驗證」。如果有任何測試爲此而不是爲本地命名模式添加下劃線? –
根據RFC的規定,本地主機名仍不允許有下劃線。如果業務需求決定他們有一個,那麼寫一個自定義驗證器來接受它們。我的正則表達式grokking技能並不總是最好的,但我認爲'最後機會'驗證器是檢查'test.local'或'mydevdomain'這些有效的主機名,而不是tld的域。 –
非常感謝+1的提升。有沒有辦法在驗證中允許特殊字符?也許是一個覆蓋功能? –