• Lin Zhang 4
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi there,
  I have been trying to parse the following xml data in apex class, but alway got issue.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <LimitInfoHeader>
         <limitInfo>
            <current>1699</current>
            <limit>8263200</limit>
            <type>API REQUESTS</type>
         </limitInfo>
      </LimitInfoHeader>
   </soapenv:Header>
   <soapenv:Body>
      <createResponse>
         <result>
            <id>0C9170000008OmqCAE</id>
            <success>true</success>
         </result>
         <result>
            <id>0C9170000008OmrCAE</id>
            <success>true</success>
         </result>
      </createResponse>
   </soapenv:Body>
</soapenv:Envelope>

The testing code I am using for testing is the following, but responseCreateResponse is alway null when running the code in developer console. I am wondering if I missed anything in my code.
//string xmlString = '<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com"><soapenv:Header><LimitInfoHeader><limitInfo><current>1699</current><limit>8263200</limit><type>API REQUESTS</type></limitInfo></LimitInfoHeader></soapenv:Header><soapenv:Body><createResponse><result><id>0C9170000008OmqCAE</id><success>true</success></result><result><id>0C9170000008OmrCAE</id><success>true</success></result></createResponse></soapenv:Body></soapenv:Envelope>';
       Dom.Document doc = new Dom.Document();
       doc.load(xmlString);

       Dom.XMLNode responseEnvelope = doc.getRootElement();
       String soapenv = 'http://schemas.xmlsoap.org/soap/envelope/';
       if (responseEnvelope != null) {
           system.debug('responseEnvelope: '+responseEnvelope);
           Dom.XMLNode responseBody = responseEnvelope.getChildElement('Body', soapenv);
           if (responseBody != null) {
               system.debug('responseBody: '+responseBody);
               Dom.XMLNode responseCreateResponse = responseBody.getChildElement('createResponse', null);
               if (responseCreateResponse != null){
                   system.debug('responseCreateResponse: '+responseCreateResponse);
                  for(Dom.XMLNode child : responseCreateResponse.getChildElements()) {
                       //System.debug(child.getText());
                       system.debug('id: ' + child.getChildElement('id', null).getText());
                       system.debug('success: ' + child.getChildElement('success', null).getText()); 
                   }                
               }
           }   
       }

 
I am building a continuous delivery pipline with ant migration tool and encounted one issue. where do I put ant-salesforce.jar? I can't put it in apache-ant lib folder on host because host created on demand. I was hoping I can specify its locatoin in build.xml file. I took sample build.xml file to try:
build.xml:
    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
        <classpath>
            <pathelement location="../ant-salesforce.jar" />
        </classpath>
    </taskdef>

It doesn't work when running ant tool. it complanins about ant-salesforce.jar is not a JAR.
Can someone suggest a solution?
Thanks!
Lin