예제 #1
0
 public function __construct($merchantKey, $wsdlUrl = self::WSDL_PRODUCTION_URL, $options = array())
 {
     $this->merchantKey = $merchantKey;
     $defaultOptions = array('encoding' => 'UTF-8', 'trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_BOTH);
     $mergedOptions = array_merge($defaultOptions, $options);
     $this->soapClient = new SoapClient($wsdlUrl, $mergedOptions);
     $this->soapClient->setKeepNullProperties(false);
     $this->soapClient->setLowerCaseFirst(true);
 }
 /**
  * Возвращает результат сервисного взаимодействия
  * @param string $method имя метода
  * @param array  $args   аргументы
  * @return Response
  */
 protected function implementationCall($method, array $args = [])
 {
     try {
         $args = array_merge($this->defaultArgs, $args);
         $result = $this->impl->__soapCall($method, $args);
         if (isset($this->config['__map'][$method])) {
             $result = $this->impl->mapSoapResult($result, $method, $this->config['__map']);
         }
         return Response::success($result);
     } catch (SoapFault $e) {
         $message = $e->getMessage();
         $this->loggerNotice($message, AbstractLogger::ERROR);
         return Response::failure(null, $message);
     }
 }
예제 #3
0
 /**
  * testDoRequestWithNamespace
  */
 public function testDoRequestWithNamespace()
 {
     $wsdlUrl = 'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL';
     $actionName = 'GetCityForecastByZIP';
     $soapClient = new Client($wsdlUrl);
     //$soapClient->setDebug(true);
     //$soapClient->setDebugLogFilePath(__DIR__ . '/../../../../log/debug.log');
     $getForecastByZip = new GetCityForecastByZIP();
     $getForecastByZip->ZIP = '90210';
     $soapResult = $soapClient->GetCityForecastByZIP($getForecastByZip);
     $resultClassNamespace = '\\Camcima\\Soap\\Test\\Fixtures\\';
     $resultClassmap = array('array|Forecast' => '\\Camcima\\Soap\\Test\\Fixtures\\ForecastEntry');
     $getCityForecastByZIPResult = $soapClient->mapSoapResult($soapResult, 'GetCityForecastByZIPResult', $resultClassmap, $resultClassNamespace);
     /* @var $getCityForecastByZIPResult \Camcima\Soap\Test\Fixtures\GetCityForecastByZIPResult */
     $this->assertInstanceOf('\\Camcima\\Soap\\Test\\Fixtures\\GetCityForecastByZIPResult', $getCityForecastByZIPResult);
     $this->assertTrue($getCityForecastByZIPResult->Success);
     $this->assertInternalType('string', $getCityForecastByZIPResult->ResponseText);
     $this->assertEquals('City Found', $getCityForecastByZIPResult->ResponseText);
     $this->assertInternalType('string', $getCityForecastByZIPResult->State);
     $this->assertEquals('CA', $getCityForecastByZIPResult->State);
     $this->assertInternalType('string', $getCityForecastByZIPResult->City);
     $this->assertEquals('Beverly Hills', $getCityForecastByZIPResult->City);
     $this->assertInternalType('string', $getCityForecastByZIPResult->WeatherStationCity);
     $forecastResult = $getCityForecastByZIPResult->ForecastResult;
     /* @var $forecastResult \Camcima\Soap\Test\Fixtures\ForecastResult */
     $this->assertInstanceOf('\\Camcima\\Soap\\Test\\Fixtures\\ForecastResult', $forecastResult);
     $this->assertInternalType('array', $forecastResult->Forecast);
     $forecasts = $forecastResult->Forecast;
     $firstForecast = reset($forecasts);
     /* @var $firstForecast \Camcima\Soap\Test\Fixtures\ForecastEntry */
     $this->assertInstanceOf('\\Camcima\\Soap\\Test\\Fixtures\\ForecastEntry', $firstForecast);
     $this->assertInstanceOf('\\DateTime', $firstForecast->Date);
     $this->assertInternalType('int', $firstForecast->WeatherID);
     $this->assertInternalType('string', $firstForecast->Desciption);
     $temperatures = $firstForecast->Temperatures;
     /* @var $temperatures \Camcima\Soap\Test\Fixtures\Temperatures */
     $this->assertInstanceOf('\\Camcima\\Soap\\Test\\Fixtures\\Temperatures', $temperatures);
     $this->assertInternalType('string', $temperatures->MorningLow);
     $this->assertInternalType('string', $temperatures->DaytimeHigh);
     $probPrecipitation = $firstForecast->ProbabilityOfPrecipiation;
     /* @var $probPrecipitation \Camcima\Soap\Test\Fixtures\ProbabilityOfPrecipiation */
     $this->assertInstanceOf('\\Camcima\\Soap\\Test\\Fixtures\\ProbabilityOfPrecipiation', $probPrecipitation);
     $this->assertInternalType('string', $probPrecipitation->Nighttime);
     $this->assertInternalType('string', $probPrecipitation->Daytime);
 }
예제 #4
0
 /**
  * testDoRequestWithArrayResponse
  */
 public function testDoRequestWithArrayResponse()
 {
     $wsdlUrl = 'http://soap-server.pacura.pl/?wsdl';
     $soapClient = new Client($wsdlUrl);
     $soapResponse = $soapClient->getForecastIcons();
     $icons = $soapClient->mapSoapResult($soapResponse, 'getForecastIconsOut', array('getForecastIconsOut' => 'array'));
     $this->assertInternalType('array', $icons);
     $this->assertArrayHasKey(0, $icons);
     $this->assertInternalType('string', $icons[0]);
     $this->assertEquals('partly-cloudly.png', $icons[0]);
 }