Forum » Pomoč in nasveti » Javascript in SOAP request
Javascript in SOAP request
Serpa ::
Zdravo,
imam problem pri sprejemanju podatkov s spletnega servisa. Pošljem request z
...
Koda se izvede brskalnik dobi
Problem je da z Wireshar-om vidim, da sem željen odgovor dobil.
Če mi brskalnik prepreči vpogled v podatke zaradi crossdomain blokiranja, kako lahko že prejete podatke kljub temu uporabim?
Uproabil sem brskalnik firefox in chrome.
Prosim za kakšen dober nasvet.
Koda:
imam problem pri sprejemanju podatkov s spletnega servisa. Pošljem request z
xmlhttp.open('POST', 'http://www.ebob42.com/cgi-bin/Romulan.exe/soap/IRoman', true)
...
xmlhttp.send(data);
Koda se izvede brskalnik dobi
200 OKvendar je response prazen.
Problem je da z Wireshar-om vidim, da sem željen odgovor dobil.
Če mi brskalnik prepreči vpogled v podatke zaradi crossdomain blokiranja, kako lahko že prejete podatke kljub temu uporabim?
Uproabil sem brskalnik firefox in chrome.
Prosim za kakšen dober nasvet.
Koda:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>SOAP Request</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> var xmlhttp; function doRequest() { log("0"); var data = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""+ " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""+ " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""+ " xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\""+ " xmlns:n=\"x\">\n"+ "<soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\""+ " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"+ "<n:IntToRoman>\n"+ "<Int xsi:type=\"soapenc:long\">1929</Int>\n"+ "</n:IntToRoman>\n"+ "</soap:Body>\n"+ "</soap:Envelope>\n";//*/ if (window.XMLHttpRequest) { // Mozilla/Safari xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } log("1"); xmlhttp.open('POST', 'http://www.ebob42.com/cgi-bin/Romulan.exe/soap/IRoman', true); xmlhttp.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); xmlhttp.setRequestHeader("Content-length", data.length); xmlhttp.setRequestHeader("Connection", "keep-alive"); log("2"); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { log("ReadyState = " + xmlhttp.readyState + "; Status = " + xmlhttp.status + "; Text: " + xmlhttp.responseText); //if (xmlhttp.status == 200) { if (xmlhttp.responseXML != null) { document.getElementById("data").textContent = "Data: " + xmlhttp.responseText; parseResult(xmlhttp.responseXML); } else { document.getElementById("data").textContent = document.getElementById("data").textContent + "Data: null"; } } //} } log("6"); //send data xmlhttp.send(data); log("7"); } function log(str) { document.getElementById("p").textContent = document.getElementById("p").textContent + "; \n" + str; } function parseResult(result) { var xmlobject = (new DOMParser()).parseFromString(result, "text/xml"); var string = (new XMLSerializer()).serializeToString(xmlobject); alert(string); } </script> </head> <body> <p id="p">Stanje</p> <p id="data">Stanje</p> <input type="submit" value="run" onclick="doRequest()"/> </body> </html>
- spremenil: Serpa ()
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | AJAX težavaOddelek: Programiranje | 1727 (1196) | tadejp81 |
» | AJAX kratke nalogeOddelek: Izdelava spletišč | 2299 (1766) | Yacked2 |
» | [javascript] zazeni, pocakaj, osveziOddelek: Programiranje | 999 (832) | detroit |
» | [ajax] osnoveOddelek: Programiranje | 1075 (919) | Volk| |
» | AJAX neznana težavaOddelek: Programiranje | 1213 (1007) | luksorzi |