I want to call SAP web service using JavaScript. Its urgent. Can anyone help me?
-
-
Answer:
Try Soap to JSON, disclaimer, it is our product and it is freemium.
Akash Kava at Quora Visit the source
Other answers
hi Aakash please check my code its give me null value <html> <head> <title> Hello</title> <script src="http://wbsp.arb.ltu.se/Motionbase/workingdocs/xmpp-code/xml_for_script-3.1/jsXMLParser/compressed/tinyxmlw3cdom.js"></script> <script src="http://wbsp.arb.ltu.se/Motionbase/workingdocs/xmpp-code/xml_for_script-3.1/jsXMLParser/compressed/tinyxmlsax.js"></script> </head> <body> <script> alert("Hello"); var username = "TTCOSNJ09624"; var password = "computer1!"; var baseURL = " "; var dparameter = null; var interval = null; var serviceName = "ZMATERIAL_DTL2"; var clientID = "250"; var operationName = "ZMATERIAL_DTL2"; var speedoCaption = "Demo Service"; //getHTTPObject(); callService(); function getHTTPObject() { var xmlhttp; if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } function callService() { http = getHTTPObject(); // this is our HTTP Object try { http.open("GET"," !", true); //http.open("POST", baseURL + "/sap/bc/srt/rfc/sap/" + serviceName + "?sap-client=250&wsdl=1.1&sap-user=" + username + "&sap-password=" + password, true); //alert("Call Service"); //var service = SOAP.connect(" "); //alert(service.readyState); //alert(service.status); } catch (exc) { alert(exc); //print(exc); } http.onreadystatechange = handleHttpResponse; http.setRequestHeader("Man","POST /sap/bc/srt/rfc/sap/" + serviceName + "?sap-client=250 HTTP/1.1"); http.setRequestHeader("Host", baseURL); //var token = username + ":" + password; //document.write(btoa(token)); var base_auth = "Basic VFRDT1NOSjA5NjI0OmNvbXB1dGVyMSE="; http.setRequestHeader("Authorization", base_auth); http.setRequestHeader("Content-Type", "text/xml; charset=ISO-8859-1"); http.setRequestHeader("Access-Control-Allow-Origin","*"); http.setRequestHeader("Access-Control-Allow-Methods", "POST"); http.setRequestHeader('Access-Control-Allow-Headers','Origin, X-Requested-With, Content-Type, Accept'); http.withCredentials=true; // http.setRequestHeader("SoapAction", ""); //var xmls = http.responseText; //alert(xmls); var xmlstring = "<?xml version='1.0' encoding='utf-8' ?>" + "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:sap-com:document:sap:soap:functions:mc-style'>" + "<soapenv:Header/>" + "<soapenv:Body>" + " <urn:ZrfcMaterialDisplay>" + " <IMakt>" + " <item>" + " <Mandt>" + " </Mandt>" + " <Matnr>" + " </Matnr>" + " <Spras>" + " </Spras>" + " <Maktx>" + " </Maktx>" + " <Maktg>" + " </Maktg>" + " </item>" + " </IMakt>" + " <Matnr>" + " WINGER" + " </Matnr>" + " <Spras>" + " E" + " </Spras>" + " </urn:ZrfcMaterialDisplay>" + " </soapenv:Body>" + " </soapenv:Envelope>"; alert("ss"); http.send(xmlstring); alert("response handled"); } function handleHttpResponse() { if (http.readyState == 4 ) { alert("readystate ="+http.readyState); if (http.status == 200) { alert("status="+http.status); var xmlfile = http.responseText; //var xmls = http.responseXML; // alert(xmls); alert(xmlfile); //instantiate the W3C DOM Parser var parser = new DOMImplementation(); alert("instantiate the W3C DOM Parser"); //alert(parser); //load the XML into the parser and get the DOMDocument var domDoc = parser.loadXML(xmlfile); <!-- var domDoc = parser.loadXML(xmlstring); --> alert("load the XML into the parser and get the DOMDocument"); // alert(domDoc); //get the root node (in this case, it is ROOTNODE) var docRoot = domDoc.getDocumentElement(); alert("get the root node (in this case, it is ROOTNODE)"); //alert(docRoot); //get the first "TAG1" element var firstTag1 = docRoot.getElementsByTagName("item").item(0); //var firstTag1 = docRoot.getElementsByTagName("xsd:se").item(0); //var firstTag1 = docRoot.getElementsByTagName("wsdl:portType").item(0); alert("get the first element"); //alert(firstTag1.getLength()); alert(firstTag1); //display the data alert(firstTag1.getFirstChild().getNodeValue()); alert("hi5"); } else alert(http.status); } } </script> </body> </html>
Ashvini Deshmukh
Related Q & A:
- Can anyone help me do a website?Best solution by Yahoo! Answers
- Can anyone help me get directions to Commonwelath park in beaverton oregon?Best solution by Yahoo! Answers
- Can anyone help me fix my MSN Keyboard Trouble?Best solution by Yahoo! Answers
- Can anyone help me with Windows Automatic Updates?Best solution by Yahoo! Answers
- Can anyone help with the Myspace graphic?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.