IONIC | SOAP based web-service | exception: 'Access-Control-Allow-Origin' missing

北城以北 提交于 2020-01-24 09:29:42

问题


I am developing mobile application using IONIC framework and I want to access SOAP based web-service, i have found this TUTORIAL.

I am accessing publicly deployed soap based web-service. I have tested the mentioned SOAP based web-service in SOAP-UI and i am able to access the web-service, but when i am accessing the same web-service from ionic framework, it throws an exception:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.webservicex.net/globalweather.asmx?wsdl. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

Can anyone let me know whats the issue?


回答1:


CORS is something that is enabled on the server. you have to make sure that the headers that are sent by the queried server have

Access-Control-Allow-Origin *;

Once that is done, the issue should be resolved. The XML request is being blocked in your case, because these headers are not present in the server response.

More info can be found here, http://www.w3.org/wiki/CORS_Enabled

BUT

For development purpose you can try to use chrome extension as workaround in your development phase.

try it: https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi

NOTE: In Production you should enable it on your server side. But during development, you can try plug-in to disable security.




回答2:


It might be the whitelisting problem. Install ionic whitelist plugin via this command:

ionic plugin add https://github.com/apache/cordova-plugin-whitelist.git

Try whitelisting all network traffic via in your 'config.xml':

<allow-navigation href="*" />

Thou , this practice of is usually not recommended.

More info here: http://docs.ionic.io/docs/cordova-whitelist



来源:https://stackoverflow.com/questions/33734419/ionic-soap-based-web-service-exception-access-control-allow-origin-missin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!