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
StreepieStreepie 

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()); 

 

 

why?

 

public class SFService {

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

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

   //construct an HTTP request
   HttpRequest req = new HttpRequest();
   req.setEndpoint('http://www.url.com/cgi-bin/jsmdirect?SFservice');
   req.setMethod('POST');
   req.setHeader('Content-Type', 'text/xml; charset=utf-8');

   // Create the soap message envelope 
   String soapMsg = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soapserver.jsm.marktselect.com">'+
                       '<soapenv:Header/>'+
                           '<soapenv:Body>'+
                             '<soap:NewAccount>'+
                             '<soap:UserId>'+uid+'</soap:UserId>'+
                             '<soap:UserPw>'+upw+'</soap:UserPw>'+
                             '<soap:Mskey>'+mskey+'</soap:Mskey>'+
                          '</soap:NewAccount>'+
                       '</soapenv:Body>'+
                    '</soapenv:Envelope>';
                
   // set the soapbody to the message envelope                 
   req.setBody(soapMsg);




   //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) 
SuperfellSuperfell
http://developer.force.com/codeshare/apex/ProjectPage?id=a0630000002ahp5AAA

All Answers

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

Hi, 

 

The error is: Invalid type: XMLDom 

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

SuperfellSuperfell
http://developer.force.com/codeshare/apex/ProjectPage?id=a0630000002ahp5AAA
This was selected as the best answer