Closed lorenzosfarra closed 9 years ago
When you use:
file:///android_asset/www/js/jquery.soap.js
and
http://<soapurl_here>/api/?wsdl
You will indeed get a
Uncaught Error: Unexpected Content: null
Due to same-origin policy... Try not to use file://
but only http://
for your test-setup. Based on the info you provided my guess is there is your problem, good luck!
Hi, first of all thanks for your reply.
It's quite strange because the same-origin policy is "solved" by phonegap using the concept of whitelist. I am using the <access origin="*" />
setting, both for android and iOS (and on iOS works), and the code is equivalent. This is why I am completely stuck, asking for your hints.
[UPDATE] And it seems that:
Luckily since your PhoneGap application is running off of the file:// protocol it isn't limited by the same origin policy. This means we can request data using XmlHttpRequest from any domain.
as stated in different documents like this blog post
Thanks!
Well in that case I suspect The problem to be with phonegap, The error is clearly pointing in the direction of same origin policy problems...
Yep, at this point I agree...totally something not related to this library, thanks for your answers anyway.
Unfortunately I have no experience with phonegap, so I won't be able to help you any further... When you do find some interesting information, please consider sharing it here, you might be helping other phonegap/jquery.soap programmers with your findings! =]
good luck!
Hi there, I recently have done an phonegap iOS and Android App for an client of mine that is now in stores and uses jquery.soap to contact a SOA-Webservice. It was a little bit of pain at first but then works out fine. I will give you some code snippets of mine, maybe that helps.
var Network = {
soapRequestInit: function () {
$.soap({
url: 'http://www. [ yourURLHere ] .asmx',
soap12: true,
appendMethodToURL: false,
namespaceQualifier: '[ yourNamespaceQualifier ]',
namespaceURL: 'http://www. [ yourURLHere ] .asmx',
});
},
logIn: function (password, name, saveit) {
$.soap({
SOAPAction: 'http://www. [ yourURLHere ] .asmx/LogIn',
method: 'LogIn',
data: {
userName: name,
password: password
},
beforeSend: function (obj) {
console.log("soap-env: " + obj.toString());
},
success: function (soapResponse) {
//...do the relevant stuff
//...
},
error: function (SOAPResponse) {
console.log("Error: " + SOAPResponse.statusText);
$.mobile.loading('hide');
//...do the relevant stuff
//...
}
});
},
//...other methods of the Network-Object
//...
}
I did not have to whitelist anything, there where just a couple of headers that had to be set at the webservice for output. These where the following: Access-Control-Allow-Origin: * Access-Control-Allow-Headers : SOAPAction und/oder Content-Type
If these headers are set on the response it should work fine.
Thanks for the reply! I will take inspiration from the above code to try something in the one I have, thanks.
Hello! Here's the problem... The same code works if I run this on the iOS simulator, but on Android I have the following error:
The code is very easy, as I'm only testing some features. So the code to include js files is the following:
`
in app.initialize I wait for the "deviceready" event to fire the following jquery soap call:
Any hints?
Thanks in advance!