Advertisement
Guest User

Consume SOAP from SAP BW via Javascript

a guest
Feb 14th, 2014
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>  
  2.     <head>
  3.         <script>  
  4.             var xmlhttp = new XMLHttpRequest();  
  5.             xmlhttp.open('POST','http://domain:8000/sap/bc/soap/rfc/test_ws/100/test_ws/zbwf_test_ws', 'user', 'pass');  
  6.             var sr =  
  7.                 '<?xml version="1.0" encoding="utf-8"?>' +
  8.                 '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style">'+
  9.                 '<soapenv:Header/>' +
  10.                 '<soapenv:Body>' +
  11.                     '<urn:function1>' +
  12.                         '<param1>14021409094682</param1>' +
  13.                     '</urn:function1>' +
  14.                 '</soapenv:Body>' +
  15.                 '</soapenv:Envelope>';
  16.                
  17.             xmlhttp.onreadystatechange = function(){  
  18.                 console.log(xmlhttp.responseText);  
  19.             }  
  20.             xmlhttp.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');  
  21.             /* Test to overcome SOP
  22.             xmlhttp.setRequestHeader("Authorization", "Basic " + btoa('user' + ":" + 'admin'));
  23.             xmlhttp.setRequestHeader("Access-Control-Allow-Origin", "*");
  24.             xmlhttp.setRequestHeader("Access-Control-Allow-Credentials", "true");
  25.             xmlhttp.setRequestHeader("Access-Control-Allow-Methods", "OPTIONS, GET, POST");
  26.             xmlhttp.setRequestHeader("Access-Control-Allow-Headers", "Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control")
  27.             */
  28.             var result = xmlhttp.send(sr);  
  29.             console.log(result);  
  30.         </script>  
  31.     </head>  
  32.    
  33.     <body></body>  
  34.    
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement