public function testShouldHandleSOAPVersion12() { $expectedHeader = 'application/soap+xml; charset=utf-8; action="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"'; $this->soapHook->enable($this->getHeaderCheckCallback($expectedHeader)); $client = new \SoapClient('http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', array('soap_version' => SOAP_1_2)); $client->setLibraryHook($this->soapHook); $client->GetCityWeatherByZIP(array('ZIP' => '10013')); }
public function getTemperature($zip) { if (empty($zip)) { throw new \InvalidArgumentException('Invalid zip provided.'); } $client = new \SoapClient(self::CDYNE_WSDL, array('soap_version' => SOAP_1_2)); $response = $client->GetCityWeatherByZIP(array('ZIP' => $zip)); return (int) $response->GetCityWeatherByZIPResult->Temperature; }
public function testShouldInterceptSoapLibrary() { VCR::configure()->enableLibraryHooks(array('soap')); VCR::turnOn(); VCR::insertCassette('unittest_soap_test'); $client = new \SoapClient('http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', array('soap_version' => SOAP_1_2)); $actual = $client->GetCityWeatherByZIP(array('ZIP' => '10013')); $temperature = $actual->GetCityWeatherByZIPResult->Temperature; $this->assertEquals('1337', $temperature, 'Soap call was not intercepted.'); VCR::eject(); VCR::turnOff(); }