Monday 15 August 2011

javascript - Error SOAP with jQuery -



javascript - Error SOAP with jQuery -

thank helping, know there lot of people has kind of issues, i've tried lot of ways solve it.

what want send , receive simple html5 file, "translate" phonegap webapp.

the problem typical issue "no 'access-control-allow-origin' header nowadays on requested resource."

i have soap service , construction must work follow:

<?xml version='1.0' encoding="utf-8"?> <soap-env:envelope xmlns:soap-env=”http://schemas.xmlsoap.org/soap/envelope/”> <soap-env:body> <m:query xmlns:m=”http://www.incits.org/rtls/"> <queryname>rtls_blinks</queryname> <filterby> <rtlsblinktime><![cdata[>2010-12-01t00:00:00z]]></ rtlsblinktime> <or/> <batterylow>=true</batterylow> <blinking>=true</blinking> </filterby> <fields> tagid location batterylow </fields> <sortby> <field>tagid</field> <order>asc</order> </sortby> </m:query> </soap-env:body> </soap-env:envelope>

and response must this:

<soap-env:envelope xmlns:soap-env= ”http://schemas.xmlsoap.org/soap/envelope/”> <soap-env:body> <m:queryresponse xmlns:m=”http://www.incits.org/rtls/"> <queryresult> <numitems>1</numitems> <tagblinks> <tagblink> <tagid>0004a32bef24</tagid> <location> <x>157</x> <y>359</y> <z>2</z> </location> <states> <batterylow>=true</batterylow> </states> </tagblink> </tagblinks> </queryresult>

my code this:

<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>hago pruebas del soap de balmart</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> $(function() { $("#btenviar").click(function() { llamarwebservice(); homecoming false;}); }); var soapmessage; function llamarwebservice() { soapmessage = "<?xml version='1.0'" + ' encoding="utf-8"?>'; soapmessage += '<soap-env:envelope '; soapmessage+= 'xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" '; soapmessage += 'xmlns:xsd="http://www.w3.org/2001/xmlschema" '; soapmessage += 'xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">'; soapmessage += "<soap-env:body>"; //[add xml here] soapmessage+= '<m:query xmlns:m="http://www.incits.org/rtls/">'; soapmessage+= '<queryname>rtls_blinks</queryname>'; soapmessage+='<filterby/>'; soapmessage+='<fields/>'; soapmessage+='<sortby><field>tagid</field><order>asc</order></sortby>'; soapmessage+= '</m:query">'; // [end] soapmessage += "</soap-env:body>"; soapmessage += "</soap-env:envelope>"; $("#info").html("request:" + soapmessage).append("<br />"); var laurl='http://test.balmart.es:8080'; jquery.support.cors = true; $.ajax({ url: laurl, type: "post", datatype: "xml", crossdomain:true, data: soapmessage, success: exitowebservice, error: errorwebservice, contenttype: "text/xml; charset=\"utf-8\"" }); } function exitowebservice(data, textstatus, jqxhr) { $("#info").append("&eacute;xito: " + data); } function errorwebservice(jqxhr, textstatus, error) { $("#info").append("error: " + textstatus + " - " + error); } </script> </head> <body> <h2 for="texto">hola caracola¡¡¡</h2> <button id="btenviar">enviar</button> <p> el mensaje enviado es el siguiente: <br/> <small id="mensaje"></small> </p> <div id="info"></div> </body> </html>

so, can solve issue , receive info ? remember soap response xml , no json.

and dont wanna create vulnerable site including unsafe "allow access '*'... " on php. help please. give thanks you.

if problem request access-control-allow-origin header go. bet haven't tried doing request actual phone since phonegap apps won't complain header. can start chrome in 'unsafe mode' , seek doing request. first kill chrome process , open 1 time again chromium-browser --disable-web-security(it's chromium in case).

javascript jquery soap web-applications cors

No comments:

Post a Comment