2

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?

1 Answer 1

1

The error message seems to indicate the request includes a header with the name SOAPAction.

So it seems like you need to add that header name to the following part of your web.config file:

<add name="Access-Control-Allow-Headers" value="SOAPAction, Content-Type, Authorization" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.