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
user CAP Administratoruser CAP Administrator 

502 Bad Gateway after calling WS from community

Hi All, 

We had this following error : 502 (Bad Gateway) when we tried to call a WS (soap) from community.
There is no issue if we test it in admin

here the code : 


sforce.connection.remoteFunction({
              url : "https://v10-creditor.cs81.force.com/creditor/services/Soap/class/WebServiceTest",//"https://" + window.location.host + "/services/Soap/class/WebServiceTest",//"https://maps.googleapis.com/maps/api/geocode/json?address=Kensington",
            //mimeType: "text/xml",
            cache : false,
            async: false,
              requestHeaders: {"Authorization":"Bearer " + __sfdcSessionId, 
              "Content-Type":"text/xml",
                        "SOAPAction": "Hello"
                    },
              requestData: envelope.join(''),
              method: "POST",
              onSuccess : function(response) {
                  // sforce.debug.log(response);
                  console.log('response: ');
                  console.log(response);
                  var obj = JSON.stringify(xmlDoc);
                  console.log('stringify: ');
                  console.log(obj);
                   var jObj = JSON.parse(obj);
                  //alert("onSuccess: \n\n" + jObj);
                  console.log('JSON: ');
                   console.log(jObj);

                  return returnObject;
              },
              onFailure : function(response) {
                  console.log(response);
                  var parser = new DOMParser();
                  var xmlDoc = parser.parseFromString(response,"text/xml");
                  //alert("onFailure end:" + xmlDoc);
                  return returnObject;
              }
            });
            // Step 3: Get Response from GED WS - Khanh
            return returnObject;
        }

 
Andries.NeyensAndries.Neyens
And does the community user profile has access to this service ?
user CAP Administratoruser CAP Administrator
Hi Andries, 
Thanks for your response
When you say "has access to this service", you mean the class "WebServiceTest" right ? 
Andries.NeyensAndries.Neyens
Correct. also check if API user is enabled for that profile (not clear to me if it is the community user or the guest user)
user CAP Administratoruser CAP Administrator
I added the class "WebServiceTest" to the "Enabled Apex Class Access"

 User-added image
User-added image

and enabled API 
User-added image

but the issue still occurs :

User-added image


Whereas in Admin it works well : 

User-added image

Did I miss something else ? 
gustavo.leigustavo.lei
Did you find out the solution for this? I'm strugling against the same issue.