function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdjl sdfjlsdsfdjl sdfjlsd 

GET method for download WSDL

Hello

I want to download wsdl file programmaticaly, using my Web JavaScript application. First I do Oauth login and get all tokens. Then I try to download WSDL file using JavaScript:

        var xmlHttp = new XMLHttpRequest();
        xmlHttp.onload = function () {
            alert(xmlHttp.responseText);
        };
        xmlHttp.open("GET", "https://ap1.salesforce.com/soap/wsdl.jsp", true);
        xmlHttp.setRequestHeader("Authorization", "Bearer " + accessToken);
        xmlHttp.send(null);
When this code executes I always get error :

XMLHttpRequest cannot load https://ap1.salesforce.com/soap/wsdl.jsp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin MyLocalHost is therefore not allowed access. 

I've already read about CORS. Problem is that I haven't server side application and I can't manage "Access-Control-Allow .." settings. All I have is client-side JavaScript application.
Could you suggest me how can I solve this issue?

Thanks

KevinPKevinP
you'll need to find a way to access the wsdl using a cors proxy. CORS_Anywhere (https://github.com/Rob--W/cors-anywhere) is available for deployment on heroku and should serve your needs.