예제 #1
0
 public function formSOAPClient()
 {
     ini_set("soap.wsdl_cache_enabled", "0");
     // Acessando o webservice definido no método SOAPServer (acima)
     $client = new Client();
     $client->setSoapVersion(SOAP_1_2);
     try {
         $uri = Manager::getAppURL('exemplos', 'zend/soapServer?wsdl', true);
         $client->setWSDL($uri);
         $this->data->response1 = $client->method1("Teste");
         $this->data->response2 = $client->method2(10, 'Framework Maestro + Zend');
     } catch (Exception $e) {
         mdump($e->getMessage());
         mdump($e->getTraceAsString());
     }
     // Acessando um webservice externo como exemplo
     $clientCountry = new Client();
     $clientCountry->setWSDL('http://www.webservicex.net/country.asmx?WSDL');
     $countries = simplexml_load_string($clientCountry->GetCountries()->GetCountriesResult);
     $this->data->country->name = $countries->Table[29]->Name;
     $Country->CountryCode = "BR";
     $code = simplexml_load_string($clientCountry->GetCountryByCountryCode($Country)->GetCountryByCountryCodeResult);
     $this->data->country->code = 'Code: ' . $code->Table[0]->countrycode;
     $this->data->country->country = 'Country: ' . $code->Table[0]->name;
     $this->render();
 }