I'm using the lib https://github.com/doedje/jquery.soap/ to connect an ionic app to an asmx webservice. However, I'm getting an error:
XMLHttpRequest cannot load http://10.10.9.169/UserService3/WebService1.asmxgetUserbyUsername. Request header field SOAPAction is not allowed by Access-Control-Allow-Headers in preflight response. jquery.soap.js:456 Uncaught Error: Unexpected Content: undefined
Here's my controller.js code:
$scope.enterlogin = function(usern,pass) { $.soap({ url: 'http://<webservice's ip address>/UserService3/WebService1.asmx', method: 'getUserbyUsername', data: { uname: usern, passw: pass }, success: function (soapResponse) { console.log('response is = ' + soapResponse); }, error: function (soapResponse) { // show error console.log('response error is = ' + soapResponse); } }); } I've also added the following in the webservice's web.config file:
<webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> <httpHandlers> <add verb="GET,HEAD,POST,OPTIONS" path="*.asmx" type="System.Web.UI.WebServiceHandlerFactory" /> </httpHandlers> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> </customHeaders> </httpProtocol> Am I missing something?