我们目前正在考虑对一个严重依赖 Soap Web 服务的网站进行一些性能调整。但是......我们的服务器位于比利时,我们连接的网络服务位于旧金山,因此至少可以说是长途连接。
我们的网站由 PHP 驱动,使用 PHP 内置的 SoapClient 类。平均而言,调用 Web 服务需要 0.7 秒,我们每页大约执行 3-5 个请求。所有可能的请求/响应缓存都已经实现,所以我们现在正在寻找其他方法来提高连接速度。
这是实例化 SoapClient 的代码,我现在正在寻找的是其他方式/方法来提高单个请求的速度。有人有想法或建议吗?
private function _createClient()
{
try {
$wsdl = sprintf($this->config->wsUrl.'?wsdl', $this->wsdl);
$client = new SoapClient($wsdl, array(
'soap_version' => SOAP_1_1,
'encoding' => 'utf-8',
'connection_timeout' => 5,
'cache_wsdl' => 1,
'trace' => 1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
));
$header_tags = array('username' => new SOAPVar($this->config->wsUsername, XSD_STRING, null, null, null, $this->ns),
'password' => new SOAPVar(md5($this->config->wsPassword), XSD_STRING, null, null, null, $this->ns));
$header_body = new SOAPVar($header_tags, SOAP_ENC_OBJECT);
$header = new SOAPHeader($this->ns, 'AuthHeaderElement', $header_body);
$client->__setSoapHeaders($header);
} catch (SoapFault $e){
controller('Error')->error($id.': Webservice connection error '.$e->getCode());
exit;
}
$this->client = $client;
return $this->client;
}