我目前正在与SOAP服务集成,该服务定义了两个不同的服务。
WSDL的相关部分是:
<wsdl:service name="Config"> <wsdl:port name="BasicHttpBinding_IConfiguration" binding="tns:BasicHttpBinding_IConfiguration"> <soap:address location="http://nonsecure.example.com/Configuration.svc"/> </wsdl:port> <wsdl:port name="BasicHttpsBinding_IConfiguration" binding="tns:BasicHttpsBinding_IConfiguration"> <soap:address location="https://secure.example.com/Configuration.svc"/> </wsdl:port> </wsdl:service>
通过研究,我发现可以使用__setLocation()方法来控制
$client->__setLocation('https://secure.example.com/Configuration.svc');但是,我不应该直接写死它,应该根据端口优先选择https。
于是封装一个方法来优先获取https端口
function getLocationForPort($wsdl, $portName)
{
$file = file_get_contents($wsdl);
$xml = new SimpleXmlElement($file);
$query = "wsdl:service/wsdl:port[@name='$portName']/soap:address";
$address = $xml->xpath($query);
if (!empty($address))
{
$location = (string)$address[0]['location'];
return $location;
}
return false;
}用法很简单:
$client = new SoapClient($wsdl);
$sslLocation = getLocationForPort($wsdl, 'BasicHttpsBinding_IConfiguration');
if ($sslLocation)
{
$client->__setLocation($location);
}
理解抽象类最快的方法就是使用场景,最近在看布尔PHP视频中看到这样的讲解非常容易懂,分享出来。 假设如下场景: 团队准备开发某网站,表建好了,页面设计好了. ...
上家公司开发医院挂号系统,系统采用GBK编码。ajax发送的中文用户名让PHP保存为cookie出现乱码的解决方案。1.Javascript变量var user=document.getElementById('user').innerText; user=escape(u...
<?php $data=array('a'=>1,'b'=>2,'c'=>3,'d'=>4); extract($data); var_dump($a,$b,$c,$d); ?>在人人商城中捡到的...
(1).学习的目标:学会创建父子进程,并且能够区分当前进程是父还是子;了解父进程执行过程,子进程执行过程;能够用多进程执行任务(2).相关函数学习: (2.1)pcntl_fork()执行时: &nbs...
概念请参考w3school文章: redis watch ,redis exec (看完基本秒懂)(1)基本事务://连接本地的 Redis 服务 $redis = new Redis(); $redis->con...
php event扩展在windows中依赖于php_sockets扩展,因此在php.ini中必须先加载php sockets扩展,如下。extension=sockets extension=event...