Example #1
0
 /**
  * Fetches the user's transcript from the server and returns it.
  * @return array user's transcript as returned by PowerSchool
  */
 public function fetchTranscript()
 {
     $client = new \Zend\Soap\Client();
     $client->setOptions(array('uri' => 'http://publicportal.rest.powerschool.pearson.com/xsd', 'location' => $this->soap_url . 'pearson-rest/services/PublicPortalServiceJSON', 'login' => 'pearson', 'password' => 'm0bApP5', 'use' => SOAP_LITERAL));
     // This is a workaround for SoapClient not having a WSDL to go off of.
     // Passing everything as an object or as an associative array causes
     // the parameters to not be correctly interpreted by PowerSchool.
     $parameters = array('userSessionVO' => (object) array('userId' => $this->soap_session->userId, 'serviceTicket' => $this->soap_session->serviceTicket, 'serverInfo' => (object) array('apiVersion' => $this->soap_session->serverInfo->apiVersion), 'serverCurrentTime' => '2012-12-26T21:47:23.792Z', 'userType' => '2'), 'studentIDs' => $this->soap_session->studentIDs, 'qil' => (object) array('includes' => '1'));
     $transcript = $client->__call('getStudentData', $parameters);
     return $transcript;
 }
Example #2
0
 /**
  * Create SOAP client instance and initialize it with provided WSDL URL.
  *
  * @param string $wsdlUrl
  * @param string $token Authentication token
  * @return \Zend\Soap\Client
  */
 public function instantiateSoapClient($wsdlUrl, $token = null)
 {
     $accessCredentials = $token ? $token : \Magento\TestFramework\Authentication\OauthHelper::getApiAccessCredentials()['key'];
     $opts = ['http' => ['header' => "Authorization: Bearer " . $accessCredentials]];
     $context = stream_context_create($opts);
     $soapClient = new \Zend\Soap\Client($wsdlUrl);
     $soapClient->setSoapVersion(SOAP_1_2);
     $soapClient->setStreamContext($context);
     if (TESTS_XDEBUG_ENABLED) {
         $soapClient->setCookie('XDEBUG_SESSION', 1);
     }
     return $soapClient;
 }
Example #3
0
 public function performRequest($wsdl, $operation, $params, $options = array('encoding' => 'UTF-8'), $fullReponse = false)
 {
     if (!extension_loaded('soap')) {
         return 'Extension SOAP not found';
     }
     if (!isset($options['soap_version'])) {
         $options['soap_version'] = SOAP_1_1;
     }
     $client = new Zend\Soap\Client($wsdl, $options);
     $soap_params = array();
     foreach ($params as $param_name => $param_value) {
         preg_match('/^(.*)\\:(.*)$/', $param_name, $matches);
         if (count($matches) == 3) {
             if (!isset($soap_params[$matches[1]])) {
                 $soap_params[$matches[1]] = array();
             }
             $soap_params[$matches[1]][$matches[2]] = $param_value;
         } else {
             $soap_params[$param_name] = $param_value;
         }
     }
     try {
         // Set (Session) cookies before the call
         if ($this->allowCookies) {
             if (is_array($this->cookies)) {
                 foreach ($this->cookies as $cookieName => $cookieValue) {
                     $client->setCookie($cookieName, $cookieValue[0]);
                 }
             }
         }
         // Perform the SOAP request
         $result = call_user_func_array(array($client, $operation), $soap_params);
         // Pick up any new cookies from the server
         if ($this->allowCookies) {
             $last_response = $client->getLastResponseHeaders();
             $soapClt = $client->getSoapClient();
             $this->cookies = array_merge($soapClt->_cookies, $this->cookies);
         }
     } catch (SoapFault $e) {
         trigger_error($e->getMessage());
         return $e->getMessage();
     }
     // Unless the full response result is specified, only reply the returned result, and not the "out" parameter results
     if (is_object($result) && !$fullReponse) {
         $result_name = $operation . 'Result';
         if (isset($result->{$result_name})) {
             return $result->{$result_name};
         }
     }
     return $result;
 }
Example #4
0
 public function index()
 {
     $client = new Zend\Soap\Client("http://webservices.e2bs.host.intranet/server?wsdl");
     try {
         echo "<pre>" . $client->soma(1, 4) . "</pre>";
         echo "<pre>" . $client->subtrai(20, 10) . "</pre>";
         echo "<pre>" . $client->multiplica(5, 4) . "</pre>";
         echo "<pre>" . $client->divide(20, 5) . "</pre>";
     } catch (SoapFault $fault) {
         echo $fault->getMessage();
     } catch (Exception $exception) {
         echo $exception->getMessage();
     }
 }
 /**
  * @param Nexway\Data\Request $data
  *
  * @return string
  */
 private function sendRequest(Nexway\Data\Request $data)
 {
     $_wsdlHttpBinding = "";
     $_wsdlServiceName = "";
     if ($data->request instanceof Nexway\Data\Request\CatalogApi) {
         $_wsdlServiceName = "CatalogApi";
     } elseif ($data->request instanceof Nexway\Data\Request\OrderApi) {
         $_wsdlServiceName = "OrderApi";
     } elseif ($data->request instanceof Nexway\Data\Request\CustomerApi) {
         $_wsdlServiceName = "CustomerApi";
     }
     if (isset($this->config['service']['nexway']['url'][lcfirst($_wsdlServiceName)])) {
         $_wsdlHttpBinding = $this->config['service']['nexway']['url'][lcfirst($_wsdlServiceName)];
     }
     $client = new \Zend\Soap\Client();
     $client->setWSDL($_wsdlHttpBinding);
     $client->setOptions(array('soap_version' => SOAP_1_1));
     preg_match('/(?P<methodName>[^\\\\]+)$/i', get_class($data->request), $_matches);
     $methodName = $_matches['methodName'];
     return $client->{$methodName}($data);
 }
Example #6
0
 public function testSetWSDLGetWSDLWithSoapClient()
 {
     $wsdl = 'http://example.com/somewhere.wsdl';
     $mailMerge = new MailMerge();
     $soapClient = new \Zend\Soap\Client();
     $soapClient->setWSDL($wsdl);
     $mailMerge->setSoapClient($soapClient);
     $this->assertTrue($wsdl === $mailMerge->getWSDL());
     unset($mailMerge);
 }
Example #7
0
<?php

/***
 * SOAP client example - Alejandro Martinez (almarag@gmail.com)
 * This is the SOAP client part for the webservice example.
 * I used Zend\Soap\Client since I'm using Zend\Soap libraries but
 * this can be also implemented using SoapClient PHP class.
 * However, Zend\Soap\Client gives more power and options to handle
 * things like encoding, authentication and other specific stuff which 
 * is more convenient than trying to do manually with SoapClient. 
 * Example is pretty straighforward. You can also found on this folder
 * a SOAPUI example for testing purposes. SOAPUI is a nice tool to
 * test SOAP/REST webservices. Check http://www.soapui.org/ for more information.
 ***/
$loader = (require 'vendor/autoload.php');
$client = new Zend\Soap\Client("http://192.168.1.108:8080/webservicetest/server.php?wsdl", array('encoding' => 'UTF-8'));
$result = $client->helloWorld();
echo $result;
Example #8
-1
 /**
  * Attempt to authenticate against the server
  * @param string $url URL for the PowerSchool server to authenticate against
  * @param string $username student's username
  * @param string $password student's password
  * @param boolean $fetch_transcript fetch transcript after successful login?
  * @return PowerAPI\Student
  */
 public static function authenticate($url, $username, $password, $fetch_transcript = true)
 {
     // Ensure the URL ends with a /
     if (substr($url, -1) !== "/") {
         $url = $url . "/";
     } else {
         $url = $url;
     }
     $client = new \Zend\Soap\Client();
     $client->setOptions(array('uri' => 'http://publicportal.rest.powerschool.pearson.com/xsd', 'location' => $url . 'pearson-rest/services/PublicPortalServiceJSON', 'login' => 'pearson', 'password' => 'm0bApP5', 'use' => SOAP_LITERAL));
     $login = $client->__call('login', array('username' => $username, 'password' => $password, 'userType' => 2));
     // userSessionVO is unset if something went wrong during auth.
     if ($login->userSessionVO === null) {
         throw new Exceptions\Authentication($login->messageVOs->description);
     }
     $session = $login->userSessionVO;
     return new Data\Student($url, $session, $fetch_transcript);
 }
Example #9
-1
 /**
  * Perform a SOAP call but first check for adding STS Token or fetch one
  *
  * @param string $name
  * @param array  $arguments
  * @return mixed
  */
 public function __call($name, $arguments)
 {
     /**
      * add WSSE Security header
      */
     if ($this->_tokenService !== null) {
         // if login method we addWsseLoginHeader
         if (in_array('login', $arguments)) {
             $this->addWsseLoginHeader();
         } elseif ($name == 'getTokens') {
             $this->addWsseTokenHeader($this->_tokenService->getLoginToken());
         } else {
             $this->addWsseSecurityTokenHeader($this->_tokenService->getTokens());
         }
     }
     return parent::__call($name, $arguments);
 }