/**
  * Set soap cookie
  *
  * @param string $name
  * @param string $value
  * 
  * @return PiSoapClientManager
  */
 public function setCookie($name, $value)
 {
     if ($this->soapClient instanceof \SoapClient) {
         $this->soapClient->__setCookie($name, $value);
     }
     return $this;
 }
Example #2
0
 public function __setCookie($name, $value = null)
 {
     if (!isset($this->_data['cookies'])) {
         $this->_data['cookies'] = [];
     }
     $this->_data['cookies'][$name] = $value;
     parent::__setCookie($name, $value);
 }
Example #3
0
 /**
  * @return bool
  * @throws Exception
  */
 public function login()
 {
     if ($this->_isAuth === true) {
         return;
     }
     $this->open();
     $this->soap->__setCookie('SOAPClient', $this->call('login', [$this->login, $this->password])->status->message);
     $this->_isAuth = true;
     return true;
 }
Example #4
0
 /**
  * Wait for the request termination and return its result.
  *
  * @return mixed
  */
 public function getResult()
 {
     if ($this->_isSynchronized) {
         return $this->_result;
     }
     $this->_isSynchronized = true;
     // Wait for a result.
     $response = self::$_curl->getResult($this->_handler);
     try {
         if ($response['result_timeout'] == 'data') {
             // Data timeout.
             throw new \SoapFault("HTTP", "Response is timed out");
         }
         if ($response['result_timeout'] == 'connect') {
             // Native SoapClient compatible message.
             throw new \SoapFault("HTTP", "Could not connect to host");
         }
         if (!strlen($response['body'])) {
             // Empty body (case of DNS error etc.).
             throw new \SoapFault("HTTP", "SOAP response is empty");
         }
         // Process cookies.
         foreach ($this->_extractCookies($response['headers']) as $k => $v) {
             if ($this->_isCookieValid($v)) {
                 $this->_client->__setCookie($k, $v);
             }
         }
         // Run the SOAP handler.
         $this->_result = $this->_client->__soapCallForced($response['body'], $this->_callArgs);
     } catch (\Exception $e) {
         // Add more debug parameters to SoapFault.
         $e->location = $this->_request['location'];
         $e->request = $this->_callArgs;
         $e->response = $response;
         throw $e;
     }
     return $this->_result;
 }
    $request = new SoapVar('<request>
								<locale country="' . $country . '" datCountryIndicator="' . $datCountryIndicator . '" language="' . $language . '"/>
								<constructionTimeFrom>' . $constructionTimeFrom . '</constructionTimeFrom>
								<constructionTimeTo>' . $constructionTimeTo . '</constructionTimeTo>
								<restriction>' . $restriction . '</restriction>
								<vehicleType>' . $vehicleType . '</vehicleType>
								<manufacturer>' . $manufacturer . '</manufacturer>
								<baseModel>' . $baseModel . '</baseModel>
								<subModel>' . $subModel . '</subModel>
								</request>', XSD_ANYXML);
    $tag['getDriversCabOptions'] = $request;
    $prerequest = new SoapVar($tag, SOAP_ENC_OBJECT);
    $getCardata = array($prerequest);
    // Set the previously stored cookie for the request
    foreach ($keys as $k) {
        $wsdlDatei_eval2->__setCookie($k, $requestCookies[$k]);
    }
    $objConversions = $wsdlDatei_eval2->__soapCall('getDriversCabOptions', $getCardata);
    if (is_soap_fault($objConversions)) {
        trigger_error("SOAP Fault: (faultcode: {$objConversions->faultcode}, faultstring: {$objConversions->faultstring})", E_USER_ERROR);
        print_r("REQUEST-Header2: " . $wsdlDatei_eval2->__getLastRequestHeaders() . "");
        print_r("Last-REQUEST2: " . $wsdlDatei_eval2->__getLastRequest() . "");
        print_r("Last-RESPONSE2: " . $wsdlDatei_eval2->__getLastResponseHeaders() . "");
    }
    echo "<pre>";
    print_r("REQUEST-Header2: " . $wsdlDatei_eval2->__getLastRequestHeaders() . "");
    print_r("Last-REQUEST2: " . $wsdlDatei_eval2->__getLastRequest() . "");
    print_r("Last-RESPONSE2: " . $wsdlDatei_eval2->__getLastResponseHeaders() . "");
    print_r($objConversions);
    echo "</pre>";
    $wsdlDatei_eval->doLogout();
Example #6
0
<?php

$client = new SoapClient('http://dexter.barros.ws/jotag/soap.wsdl', array('trace' => true));
$client->__setCookie('JOTAGSESSION', '77f845d8ef25db15dbfbc6cfc4950e51');
print_r($client->__getFunctions());
print_r($client->soap_getLanguages());
print_r($client->soap_getCurrentLanguage());
$client->soap_setCurrentLanguage(1);
print_r($client->soap_getCurrentLanguage());
$client->soap_configureJotag('RHY 575', 'Carlos 123', array(3), null, null, null, null, null, false);
//$client->soap_login(array('email'=>'*****@*****.**','password'=>'budega'));
print_r($client->soap_getProfile());
$client->soap_saveProfile(array('first_name' => 'Testing', 'last_name' => 'Soap', 'language_id' => 2));
print_r($client->soap_getProfile());
//print_r($client->soap_viewJotag("barros",array('pin'=>'budega','message'=>'Hey man, let me in!!','captcha'=>'z48mx2')));
Example #7
0
<?php

$client = new SoapClient(null, array('uri' => 'mo:http://www.w3.org/', 'location' => 'http://some.url'));
$client->__setCookie("CookieTest", "HelloWorld");
var_dump($client->__getCookies()['CookieTest'][0]);
 /**
  * Set a cookie for this client.
  *
  * @param string $name
  * @param string $value
  * @return void
  */
 public function __setCookie($name, $value = null)
 {
     parent::__setCookie($name, $value);
     if ($value !== null) {
         $this->_cookies[$name] = $value;
     } else {
         unset($this->_cookies[$name]);
     }
 }
 /**
  * @test
  */
 public function cookie()
 {
     $obj = new CurlSoapClient(null, array('location' => 'http://localhost:8000/tests/server.php', 'uri' => 'http://test-uri/', 'trace' => true));
     $original_obj = new \SoapClient(null, array('location' => 'http://localhost:8000/tests/server.php', 'uri' => 'http://test-uri/', 'trace' => true));
     $this->assertEquals(array(), $obj->__getCookies());
     $this->assertEquals(array(), $original_obj->__getCookies());
     $obj->__setCookie('CookieTest', 'HelloWorld');
     $obj->__setCookie('CookieTest2', 'HelloWorld2');
     $original_obj->__setCookie('CookieTest', 'HelloWorld');
     $original_obj->__setCookie('CookieTest2', 'HelloWorld2');
     $this->assertEquals(array('CookieTest' => array('HelloWorld'), 'CookieTest2' => array('HelloWorld2')), $obj->__getCookies());
     $this->assertEquals(array('CookieTest' => array('HelloWorld'), 'CookieTest2' => array('HelloWorld2')), $original_obj->__getCookies());
     $this->assertEquals(array(1, 'a', false), $obj->test(array(1, 'a', false)));
     $this->assertEquals(array(1, 'a', false), $original_obj->test(array(1, 'a', false)));
     // difference of CurlSoapClient from SoapClient [";" -> "; "]
     $this->assertTrue(stripos($obj->__getLastRequestHeaders(), 'Cookie: CookieTest=HelloWorld; CookieTest2=HelloWorld2') !== false);
     $this->assertTrue(stripos($original_obj->__getLastRequestHeaders(), 'Cookie: CookieTest=HelloWorld;CookieTest2=HelloWorld2') !== false);
 }
 /**
  * @link http://php.net/manual/en/soapclient.setcookie.php
  *
  * @param string $name
  * @param string $value
  *
  * @return void
  */
 public function __setCookie($name, $value = null)
 {
     return parent::__setCookie($name, $value);
 }
Example #11
0
 /**
  * Creates a Signed Soapclient
  *
  * @param $wsdl
  * @param $options
  * @param array $params
  * @return \SoapClient
  * @throws \Exception
  */
 private function soapClient($wsdl, $options, $method, $params = [])
 {
     try {
         $client = new \SoapClient($wsdl, $options);
     } catch (\SoapFault $sf) {
         throw new \Exception(sprintf('Could not connect to endpoint: %s.', $wsdl));
     }
     // Set the cookies
     $client->__setCookie('login', $this->settings['login']);
     $client->__setCookie('mode', $this->settings['mode']);
     $timestamp = time();
     $nonce = uniqid('', true);
     $client->__setCookie('timestamp', $timestamp);
     $client->__setCookie('nonce', $nonce);
     $client->__setCookie('clientVersion', self::API_VERSION);
     $client->__setCookie('signature', $this->urlencode($this->sign(array_merge($params, array('__method' => $method, '__service' => $this->service, '__hostname' => $this->settings['endpoint'], '__timestamp' => $timestamp, '__nonce' => $nonce)))));
     // set cookie
     return $client;
 }
 /**
  * Create a SOAP client using PHP5's SOAP extension
  *
  * @param boolean $wsdlcaching True if you want the WSDL file cached
  * @param integer $cache_timeout Number of seconds to cache the WSDL file
  * @return object Returns the web service client object 
  */
 public function get_mail_client($wsdlcaching = true, $cachetime = self::cache_timeout)
 {
     // Engage WSDL caching (or not)
     if ($wsdlcaching) {
         ini_set("soap.wsdl_cache_enabled", "1");
         ini_set("soap.wsdl_cache_ttl", $cachetime);
     } else {
         ini_set("soap.wsdl_cache_enabled", "0");
     }
     // Construct the URL to send requests to. Don't forget to URL encode.
     $location = self::mail_prefix . "?appid=" . urlencode($this->appid) . "&WSSID=" . urlencode($this->WSSID);
     // Create client with different location than WSDL (must have PHP 5.04 SOAP or newer)
     $mail_client = new SoapClient(self::wsdl_path, array('location' => $location, 'exceptions' => 0));
     // Separate name from value in cookie string.
     $credential = split("=", $this->cookie);
     // Set the "Y" cookie in the SOAP client.
     $mail_client->__setCookie("Y", $credential[1]);
     return $mail_client;
 }