Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. function soap() {
  2. var xmlhttp = new XMLHttpRequest();
  3. xmlhttp.open('POST', 'http://url.1cws', true);
  4. xmlhttp.withCredentials = 1;//с это строкой и без нее результат одинаковый
  5. xmlhttp.setRequestHeader('Authorization', 'Basic ' + btoa("user:pass"));
  6.  
  7. var sr = '
  8. <v:Envelope xmlns:i="http://localhost/rt2"
  9. xmlns:d="http://localhost/rt2" xmlns:c="http://localhost/rt2"
  10. xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
  11. <v:Header />
  12. <v:Body>
  13. <GetShopCategoriesList
  14. xmlns="http://localhost/rt2" id="o0" c:root="1" />
  15. </v:Body>
  16. </v:Envelope>';
  17.  
  18. xmlhttp.onreadystatechange = function () {
  19. if (xmlhttp.readyState == 4) {
  20. if (xmlhttp.status == 200) {
  21. alert(xmlhttp.resposeText);
  22. }
  23. }
  24. }
  25. xmlhttp.send(sr);
  26.  
  27. }
  28.  
  29. $username='user';
  30. $password='pass';
  31. $URL='http://url.1cws';
  32.  
  33. $ch = curl_init();
  34. curl_setopt($ch, CURLOPT_URL,$URL);
  35. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  36. curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  37.  
  38. curl_setopt($ch, CURLOPT_POSTFIELDS, '
  39. <v:Envelope xmlns:i="http://localhost/rt2"
  40. xmlns:d="http://localhost/rt2" xmlns:c="http://localhost/rt2"
  41. xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
  42. <v:Header />
  43. <v:Body>
  44. <GetShopCategoriesList
  45. xmlns="http://localhost/rt2" id="o0" c:root="1" />
  46. </v:Body>
  47. </v:Envelope>');
  48.  
  49. $data = curl_exec($ch);
  50. curl_close($ch);
  51. echo($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement