Guest User

Untitled

a guest
Oct 28th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. $username='xxx';
  4. $password='yyy';
  5. $WSDL_URL='https://myserver.com/mywebservice?wsdl';
  6. $auth = base64_encode($username . ":" . $password);
  7.  
  8. $Header = array(
  9. 'http'=>array(
  10. 'method'=> "POST",
  11. 'header'=> "Authorization: Basic $authrn".
  12. "Content-Type: text/xmlrn".
  13. "cache-control: no-cache"
  14. )
  15. );
  16.  
  17. $HeaderContext = stream_context_create($Header);
  18.  
  19. $soap = new SoapClient(NULL, array(
  20. 'login' => $username,
  21. 'password' => $password,
  22. 'trace' => 1,
  23. 'exceptions' => 0,
  24. 'location' => $WSDL_URL,
  25. 'uri' => $WSDL_URL,
  26. 'cache_wsdl' => WSDL_CACHE_NONE,
  27. 'stream_context' => $HeaderContext
  28. ));
  29.  
  30. $response = $soap->serviceECHO( 'Hello' );
  31. print_r($response);
  32.  
  33. $username='xxx';
  34. $password='yyy';
  35. $WSDL_URL='https://myserver.com/mywebservice?wsdl';
  36. $auth = base64_encode($username . ":" . $password);
  37.  
  38. $curl = curl_init();
  39.  
  40. curl_setopt_array($curl, array(
  41. CURLOPT_URL => $WSDL_URL,
  42. CURLOPT_RETURNTRANSFER => true,
  43. CURLOPT_ENCODING => "",
  44. CURLOPT_MAXREDIRS => 10,
  45. CURLOPT_TIMEOUT => 30,
  46. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  47. CURLOPT_CUSTOMREQUEST => "POST",
  48. CURLOPT_POSTFIELDS => "
  49. <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:uet='http://myserver.com/'>
  50. <soapenv:Header/>
  51. <soapenv:Body>
  52. <uet:testMsj>Hello</uet:testMsj>
  53. </soapenv:Body>
  54. </soapenv:Envelope>",
  55. CURLOPT_HTTPHEADER => array(
  56. "Content-Type: text/xml",
  57. "cache-control: no-cache",
  58. "Authorization: Basic $auth"
  59. ),
  60. ));
  61.  
  62. $xmlResponse = curl_exec($curl);
  63. print_r($xmlResponse);
Add Comment
Please, Sign In to add comment