简体   繁体   English

如何加快php soap客户端的速度

[英]How to speedup php soap client

I'm using a web service to send SMS in PHP. 我正在使用Web服务以PHP发送短信。 The code in like below: 代码如下:

$options = array(
'login' => 'yourusername',
'password' => 'yourpassword'
);
$client = new SoapClient('http://sms.hostiran.net/webservice/?WSDL', $options);
try
{
    $messageId = $client->send(destination mobile number, 'test sms');
    sleep(3);
    print ($client->deliveryStatus($messageId));
    var_dump($client->accountInfo());
}
catch (SoapFault $sf)
{
    print $sf->faultcode."\n";
    print $sf->faultstring."\n";
}

The problem is that when i run this code on a WAMP server, it runs rapidly.But when i use this code in an ubuntu server, the speed of running this code is very low. 问题是,当我在WAMP服务器上运行此代码时,它运行很快。但是当我在ubuntu服务器中使用此代码时,运行此代码的速度非常慢。 Is there any configuration in php.ini to solve this problem ? php.ini中有任何配置可以解决此问题?

Thanks! 谢谢!

First, you need to remove sleep(3). 首先,您需要删除sleep(3)。 That makes it take an extra 3 seconds. 这将花费额外的3秒钟。

Second, it looks like the sms provider is in Iran so it'd be best for you to get a web server in Iran. 其次,sms提供商似乎在伊朗,因此最好在伊朗获得Web服务器。

As far as I know there is no reason why a Ubuntu server would be slower at SOAP than a Windows server 据我所知,没有理由使Ubuntu服务器的SOAP速度比Windows服务器慢

If you want to try and speed up the webpage what you should do is instead of running the SOAP request on page load you save the request to a database and then have a cron that runs every few minutes, pulls the requests out of the database, and makes the request. 如果您想尝试加快网页速度,而不是在页面加载时运行SOAP请求,则应将请求保存到数据库中,然后每隔几分钟运行一次cron,将请求从数据库中拉出,并提出要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM