valsaned

soaprequest

May 24th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <title>
  5. </title>
  6. <head>
  7. <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js"></script>
  8. <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
  10. <script src="https://cdnjs.cloudflare.com/ajax/libs/accounting.js/0.4.1/accounting.min.js"></script>
  11. <script src="https://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script>
  12. <script>
  13. var apptoken = "mytoken";
  14. $.ajaxSetup({data: {apptoken: apptoken}});
  15. function soapRequest(){
  16.  
  17. var str =
  18.  
  19. '<?xml version="1.0" encoding="utf-8"?>' +
  20. '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">' +
  21. '<soap:Header/>' +
  22. '<soap:Body>' +
  23. '<tem:BaixarVendas>' +
  24.  
  25. '<tem:Token>RFRTMzlfVElNX0lOT1ZBSU5GTw==</tem:Token>' +
  26. '<tem:DataInicial>2016-05-23</tem:DataInicial>' +
  27. '<tem:DataFinal>2016-05-23</tem:DataFinal>' +
  28. '</tem:BaixarVendas>' +
  29. '</soap:Body>' +
  30. '</soap:Envelope>';
  31.  
  32.  
  33.  
  34. function createCORSRequest(method, url) {
  35. var xhr = new XMLHttpRequest();
  36.  
  37. if ("withCredentials" in xhr) {
  38. xhr.open(method, url, false);
  39.  
  40. } else if (typeof XDomainRequest != "undefined") {
  41. alert("indefinido");
  42. xhr = new XDomainRequest();
  43. xhr.open(method, url);
  44. } else {
  45. console.log("CORS not supported");
  46. alert("CORS not supported");
  47. xhr = null;
  48. } return xhr;
  49. }
  50. var xhr = createCORSRequest("POST", "https://wsintegracaoclientes.datasys.online/Clientes/ConsultasDatasys.asmx?WSDL");
  51. if(!xhr){
  52. console.log("XHR issue");
  53.  
  54. return;
  55. }
  56. xhr.onload = function (){
  57. var results = xhr.responseText;
  58. console.log(results);
  59. };
  60.  
  61. xhr.setRequestHeader('Content-Type', 'text/xml');
  62.  
  63. xhr.send(str);
  64. }
  65.  
  66. </script>
  67. </head>
  68. <body>
  69.  
  70. <input type = "button" value = "SOAP Request" onclick = "soapRequest();" />
  71.  
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment