DEV Community

Hugo Queirós
Hugo Queirós

Posted on

Make a Soap call in React js by a webservice

I am doing an application on react where i need to receive some data coming from webservice. I already have the sample of soap request and response, and i already had done some request by the postman and it is working fine. But when i want to make a soap request and response on react, it ives me the same problem every time that is CORS has blocked my access to XMLHttpRequest. Is somebody able to help me?

Top comments (4)

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

Either:

  1. setup your webpackdev server to proxy to the remote host and use a relative path from your / (only if they will one day be hosted in the same domain, if they won't be on the same domain, don't do this)
  2. Enable CORS on the remote server if you have access to it or can configure a proxy in front of it
  3. Use a CORS proxy like one from here: nordicapis.com/10-free-to-use-cors...

Browsers are more picky about CORS than Postman is.

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

Use axios

Collapse
 
hugoqueiros profile image
Hugo Queirós

i have already tried that and i have the same problem

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

Your Soap api is the problem not react, you need to allow requests from your domain or localhost.