Guest User

Untitled

a guest
Aug 21st, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: nateswanson
  5. * Date: 8/21/18
  6. * Time: 10:30 AM
  7. */
  8. $api_url = 'http://spotix.local/index.php/api/soap/?wsdl';
  9. $user = 'soap_user';
  10. $pass = 'password';
  11. $params = array('location'=>$api_url, 'soap_version' => SOAP_1_1, 'encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 180);
  12. $client = new SoapClient($api_url, $params);
  13.  
  14. try{
  15. $session = $client->login($user, $pass);
  16. $result = $client->resources($session);
  17. }catch(Exception $e){
  18. echo '<pre>';
  19. print_r($client);
  20. echo '</pre>';
  21. return;
  22. }
  23.  
  24. echo '<pre>';
  25. var_dump($result);
  26. echo '</pre>';
  27.  
  28. $client->endSession($session);
  29. ?>
  30.  
  31. SoapClient Object
  32. (
  33. [location] => http://spotix.local/index.php/api/soap/?wsdl
  34. [trace] => 1
  35. [_encoding] => UTF-8
  36. [_connection_timeout] => 180
  37. [_soap_version] => 1
  38. [sdl] => Resource id #2
  39. [__last_request] =>
  40. soap_userpassword
  41.  
  42. [httpsocket] => Resource id #3
  43. [_use_proxy] => 0
  44. [httpurl] => Resource id #4
  45. [__last_request_headers] => POST /index.php/api/soap/?wsdl HTTP/1.1
  46. Host: spotix.local
  47. Connection: Keep-Alive
  48. User-Agent: PHP-SOAP/5.6.36
  49. Content-Type: text/xml; charset=utf-8
  50. SOAPAction: "urn:Mage_Api_Model_Server_HandlerAction"
  51. Content-Length: 540
  52.  
  53.  
  54. [__last_response_headers] => HTTP/1.1 200 OK
  55. Date: Tue, 21 Aug 2018 20:22:29 GMT
  56. Server: Apache
  57. X-Powered-By: PHP/5.6.36
  58. Expires: Thu, 19 Nov 1981 08:52:00 GMT
  59. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  60. Pragma: no-cache
  61. Set-Cookie: PHPSESSID=kj5rv20qo5d1s2jfj3kfo8fn31; expires=Wed, 22-Aug-2018 06:22:30 GMT; Max-Age=36000; path=/; domain=spotix.local; HttpOnly
  62. Upgrade: h2,h2c
  63. Connection: Upgrade, Keep-Alive
  64. Keep-Alive: timeout=5, max=100
  65. Transfer-Encoding: chunked
  66. Content-Type: text/xml; charset=UTF-8
  67.  
  68. [_cookies] => Array
  69. (
  70. [PHPSESSID] => Array
  71. (
  72. [0] => kj5rv20qo5d1s2jfj3kfo8fn31
  73. [1] => /
  74. [2] => spotix.local
  75. )
  76.  
  77. )
  78.  
  79. [__last_response] =>
  80.  
  81. Call api functionality
  82.  
  83.  
  84.  
  85.  
  86.  
  87. Multiple calls of resource functionality
  88.  
  89.  
  90.  
  91.  
  92.  
  93. End web service session
  94.  
  95.  
  96.  
  97.  
  98.  
  99. Login user and retrive session id
  100.  
  101.  
  102.  
  103.  
  104.  
  105. Start web service session
  106.  
  107.  
  108.  
  109.  
  110.  
  111. List of available resources
  112.  
  113.  
  114.  
  115.  
  116.  
  117. List of resource faults
  118.  
  119.  
  120.  
  121.  
  122.  
  123. List of global faults
  124.  
  125.  
  126.  
  127.  
  128.  
  129. [__soap_fault] => SoapFault Object
  130. (
  131. [message:protected] => Wrong Version
  132. [string:Exception:private] =>
  133. [code:protected] => 0
  134. [file:protected] => /private/var/www/html/soap/SOAP_test.php
  135. [line:protected] => 17
  136. [trace:Exception:private] => Array
  137. (
  138. [0] => Array
  139. (
  140. [file] => /private/var/www/html/soap/SOAP_test.php
  141. [line] => 17
  142. [function] => __call
  143. [class] => SoapClient
  144. [type] => ->
  145. [args] => Array
  146. (
  147. [0] => login
  148. [1] => Array
  149. (
  150. [0] => soap_user
  151. [1] => password
  152. )
  153.  
  154. )
  155.  
  156. )
  157.  
  158. [1] => Array
  159. (
  160. [file] => /private/var/www/html/soap/SOAP_test.php
  161. [line] => 17
  162. [function] => login
  163. [class] => SoapClient
  164. [type] => ->
  165. [args] => Array
  166. (
  167. [0] => soap_user
  168. [1] => password
  169. )
  170.  
  171. )
  172.  
  173. )
  174.  
  175. [previous:Exception:private] =>
  176. [faultstring] => Wrong Version
  177. [faultcode] => VersionMismatch
  178. [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
  179. )
  180.  
  181. )
Add Comment
Please, Sign In to add comment