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

XMLdom fails in sandbox

I have some apex-class code in a developers enviroment, works just fine!


I copy the code in a sandbox and de compilation fails on the line:


XMLDom responseXML = new XMLDom(res.getBody()); 





public class SFService {

  //Future annotation to mark the method as async.
  // methods may call this class =callout=true

   public static void SFservice(String id, String uid, String upw, Integer mskey ) {

   //construct an HTTP request
   HttpRequest req = new HttpRequest();
   req.setHeader('Content-Type', 'text/xml; charset=utf-8');

   // Create the soap message envelope 
   String soapMsg = '<soapenv:Envelope xmlns:soapenv="" xmlns:soap="">'+
   // set the soapbody to the message envelope                 

   //send the request
   Http http = new Http();
   HttpResponse res = http.send(req);
   //check the response
   if (res.getStatusCode() == 200) {
         XMLDom responseXML = new XMLDom(res.getBody());
         string rlcode = responseXML.getElementByTagName('relatiecode').nodeValue;

          //update account
          Account acc = new Account(Id=id);
          acc.AccountNumber = rlcode; 
          acc.Description = res.getStatus() ;
          update acc;
    } else {
          System.debug('Callout failed: ' + res);
          Account acc = new Account(Id=id);
          acc.Description = res.getStatus() ;
          update acc;

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

Did you install the XMLDom package in your sandbox org? what's the exact error you get?



The error is: Invalid type: XMLDom 

...where can i find the xmldom package ? do you have a link?

This was selected as the best answer