Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ERROR | E_PARSE);
  3. ini_set('display_errors', 1);
  4. ini_set('soap.wsdl_cache_enabled',0);
  5. ini_set('soap.wsdl_cache_ttl',0);
  6. ini_set('default_socket_timeout', 1000);
  7.  
  8.  
  9. $url_wsdl ="https://exampleservice.cls?WSDL=1&CacheUserName=myusername&CachePassword=mypassword&CacheNoRedirect=1";
  10.  
  11.  
  12. print 'Starting routine';
  13. //logging in
  14. $curl = curl_init($url_wsdl);
  15. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  16. curl_setopt($curl, CURLOPT_HEADER, 1);
  17. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  18. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  19. curl_setopt($curl, CURLOPT_SSLVERSION, 3);
  20.  
  21.  
  22. // get cookies
  23. preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $result, $matches);
  24. $cookies = array();
  25. foreach($matches[1] as $item) {
  26. parse_str($item, $cookie);
  27. $cookies = array_merge($cookies, $cookie);
  28. }
  29. curl_close($curl);
  30. print 'Curl....ok. Cookies ok<br>';
  31.  
  32.  
  33. $options = array(
  34. 'trace' => 1
  35. , 'cache_wsdl' => WSDL_CACHE_NONE
  36. , 'user_agent' => 'PHP WS'
  37. , 'ssl_method' => SOAP_SSL_METHOD_SSLv3
  38.  
  39. );
  40.  
  41. $soapClient = new SoapClient($url_wsdl,$options );
  42. print 'SoapClient....ok<br>';
  43.  
  44. //sending cookies to soapclient
  45. foreach ($cookies as $name => $value) {
  46. print '------> sending cookies: '. $value . '<br>';
  47. $soapClient->__setCookie($name, $value);
  48. }
  49. print 'SetCookies....ok<br>';
  50.  
  51.  
  52. $data = array('TesteInterface' => array('Request' => array('Mensagem' => 'teste')));
  53. $response = $soapClient->__soapCall("TesteInterface",$data);
  54. print 'SoapCall....ok<br>';
  55.  
  56. print 'Response:<br>';
  57. print_r($response);
  58.  
  59.  
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement