PHP SoapClient 构造函数很慢 [英] PHP SoapClient constructor very slow

查看:36
本文介绍了PHP SoapClient 构造函数很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Web 服务的新手.我遇到了莫名其妙的随机 SoapClient 构造函数执行时间.通常呼叫需要大约 10 秒钟.有时只需不到一秒钟,但这种情况发生的频率较低.

PHP SoapClient 构造器非常慢

PHP:SoapClient 构造函数非常慢(需要 3 分钟))

连接到 WCF Web 服务莫名其妙地慢

我的情况与上述线程中的情况类似,但其中提供的解决方案并没有解决我的问题.

//配置参数$params = 数组('跟踪' =>1、'soap_version' =>肥皂_1_1,'cache_wsdl' =>WSDL_CACHE_MEMORY);//这个调用大约需要 10 秒到远程 WSDL$soap_client = new SoapClient(WSDL_URL,$params);

我使用了不同的 wsdl 缓存参数,发现 WSDL_CACHE_MEMORY 是最快的.使用其他缓存选项时,调用平均需要大约 25 秒.

我没有使用多个用户.

我已将 wsdl_cache_dir 更改为 php.ini 中的 Windows 友好目录.

我的问题有两个:

  1. 为什么 SoapClient 构造函数的执行时间看起来是随机的?为什么它通常需要更长的时间,但有时只需要一瞬间?有没有我可以执行的测试来了解它为什么会这样?

  2. 我是否应该缓存/保存 SoapClient 对象或资源,以便当我的页面访问者在页面之间移动时,我不需要创建新的 SoapClient 并再次重新解析 WSDL?实现这一目标的推荐方法是什么?

我们将非常感谢您对正确方向的任何帮助或推动.谢谢.

解决方案

检查 TTL

TTL 定义了 WSDL 在缓存中存在的时间.

 soap.wsdl_cache_ttl 整数

<块引用>

设置将使用缓存文件而不是原始文件的秒数(生存时间).

http://www.php.net/manual/en/soap.configuration.php#ini.soap.wsdl-cache-ttl

在本地存储 WSDL

您也可以将 WSDL 下载到本地文件系统并将其用作 SoapClient

$client = new SoapClient("file://path/wsdl.file", array('位置' =>http://domain/ws-endpoint",));

I am new to Web Services. I am experiencing inexplicably random SoapClient constructor execution times. Usually the call takes about 10 seconds. Sometimes it takes less than one second, but this occurrence is less frequent.

PHP SoapClient Constructor extremely slow

PHP: SoapClient constructor is very slow (takes 3 minutes)

Connecting to WCF Web Service is inexplicably slow

My situation is similar to those in the above threads but the solutions provided in them didn't resolve my issue.

// config params
$params = array(
    'trace'        => 1,
    'soap_version' => SOAP_1_1,
    'cache_wsdl'   => WSDL_CACHE_MEMORY
);
// this call takes about 10 seconds to remote WSDL
$soap_client = new SoapClient(WSDL_URL,$params);

I have played with the different wsdl caching parameters and found WSDL_CACHE_MEMORY to be the fastest. When using the other caching options, the call takes about 25 seconds on average.

I am not using multiple users.

I have changed the wsdl_cache_dir to a Windows friendly directory in php.ini.

My question is two-fold:

  1. Why is the SoapClient constructor seemingly random in how long it takes to execute? Why does it usually take longer but then sometimes only takes a split second? Is there a test I can perform to learn why it's behaving this way?

  2. Should I be caching/saving the SoapClient object or resource so that when my page visitors move from page to page I don't need to create a new SoapClient and re-parse the WSDL again? What's the recommended approach to accomplish that?

Any help or nudge in the right direction would be much obliged. Thank you.

解决方案

Check the TTL

TTL defines how long the WSDL lives in cache.

 soap.wsdl_cache_ttl integer

Sets the number of seconds (time to live) that cached files will be used instead of the originals.

http://www.php.net/manual/en/soap.configuration.php#ini.soap.wsdl-cache-ttl

Store the WSDL locally

Also you could download the WSDL to the local filesystem and use it as source for SoapClient

$client = new SoapClient("file://path/wsdl.file", array(
    'location' => "http://domain/ws-endpoint",
));

这篇关于PHP SoapClient 构造函数很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆