我目前正在与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);
}
项目中使用服务来执行webservice,由于对方系统api不稳定,经常导致服务崩溃,只能重启,一个月差不多要重启一次。初期的解决办法是捕获异常,然后continue掉。<?php try { $url = 'http...
ThinkPHP中有一个debug调试功能,能输出报错文件的信息,并能看到这个函数被哪些函数调用,从框架的启动开始记录,特别方便调试。于是研究了下它的底层给予了实现。<?php //--框架核心--Start //框架内置错误处理 function errDealWith($er...
Redis提供了发布订阅功能,可以用于消息的传输,Redis的发布订阅机制包括三个部分,发布者(publisher),订阅者(subscriber)和频道(channel)。 发布者和订阅者都是Redis客户端,Channel则为Redis服务器端,发布者将消息发送到某个的频道,订阅了这个...
(1).config.php 配置文件<?php /** * RabbitMQ_Config */ $config = [ 'host' => ...
<?php //php7+ define('CONFIG', [ 'MYSQL' => '127.0.0.1',  ...
(1).管道是干嘛的?管道是用于进程之间通信的,传播或交换信息(2).管道有几种?(2.1).匿名管道(pipe):管道是一种半双工的通信方式,数据只能单向流动,而且只能在具有亲缘关系的进程间使用。通常是指父子进程关系。(2.2).高级管道(popen):将另一个程序当做一个新的进程在当前程序进程中...