• Sricharan Puligundla 11
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I am calling a web service,getting response and updating mutiple asset records in Salesforce.Response XML is given below

In the XML we have multiple values for Age.First Age value must be stored in first asset record and so on.Issue is last value of Age in the xml is stored is getting stored for all Asset Records.
My Apex class code is given below.
global class AxedaDataItemBatch1 implements Database.Batchable<sObject>,Database.AllowsCallouts{
Public String query;

String email;

Id toUserId;

Id fromUserId;
    global Database.querylocator start(Database.BatchableContext BC)
    {
       //String query = 'Select Id from Asset where SerialNumber = 'SCLP0003'';          
            return Database.getQueryLocator(query);
    }
global void execute(Database.BatchableContext BC, List<sObject> scope){

        //List<Asset> myobjects = [ select Id from Asset where SerialNumber = 'SCLP0007' ];
        List<Asset> myobjects = [ select Id from Asset where Id In ('02i54000000DdVJAA0','02i54000000DdVKAA0','02i54000000DdVRAA0','02i54000000DdViAAK','02i54000000DdW4AAK')];
       
       
        AxedaSession asp = new AxedaSession();
        String SessionId = asp.SessionId();
        System.debug('session id'+SessionId);
       
        HttpRequest req = new HttpRequest();
        HTTPResponse res;
        String AssetId = '2381';
        //Set HTTPRequest Method 
        req.setMethod('POST');
       
        //String password = 'Cynosure793*';
        //System.debug('password is'+password);
      
        //Blob headerValue = Blob.valueOf(username + ':' + password); */
      
        //String authorizationHeader = 'NTLM ' + EncodingUtil.base64Encode(headerValue);
        //String authorizationHeader = 'NTLM ' + headerValue; 
        //System.debug('authorization header is'+authorizationHeader);
 
        //req.setEndpoint('https://cynosure.axeda.com/services/v2/rest/dataItem/findCurrentValues');
        req.setEndpoint('https://cynosure.axeda.com/services/v2/rest/dataItem/findHistoricalValues');   
        //req.setEndpoint('http://www.webservicex.com/stockquote.asmx');
        req.setMethod('POST');
        //req.setMethod('findByCriteria');
        //req.setHeader('Content-Type', 'text/xml; charset=UTF-8');
        req.setHeader('Content-Type', 'application/xml');
        //req.setHeader('Content-Type', 'charset=UTF-8');
        //req.setHeader('Content-Type','application/json');
        req.setHeader('x_axeda_wss_sessionid',SessionId);
        //req.setHeader('sessionId', MySessionID);
        //req.setHeader('Authorization', authorizationHeader);  
        //req.setHeader('SOAPAction', 'http://devwdapps.cynosure.com/XiPayWSConnector/XiPayWSConnector.XiPay.svc');
        //req.setHeader('SOAPAction','http://Primesys/XiPaySoap/message/IXiPay/Authorize');
        /*string b =   '<?xml version="1.0" encoding="UTF-8"?><v2:CurrentDataItemValueCriteria xmlns:v2="http://www.axeda.com/services/v2"'+
            ' xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" sortAscending="true" sortPropertyName="Name">'+
                      '<v2:name>*</v2:name><v2:assetId>'+AssetId+'</v2:assetId>'+
                       '<v2:types/></v2:CurrentDataItemValueCriteria>';*/
        string b =   '<?xml version="1.0" encoding="UTF-8"?><v2:HistoricalDataItemValueCriteria xmlns:v2="http://www.axeda.com/services/v2"'+
            ' xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" sortAscending="true" sortPropertyName="Name">'+
                      '<v2:assetId>'+AssetId+'</v2:assetId>'+
                       '<v2:dataItemIds/></v2:HistoricalDataItemValueCriteria>';   
        req.setBody(b);
        System.debug('b is'+b);
        System.debug('request is'+req);
        Http http = new Http();
        String response;
        try { 
          //Execute web service call here        
          res = http.send(req); 
          response = res.getBody();
          System.debug(res.toString());
          System.debug(res.getBody());
          System.debug('response is'+response);
          Dom.Document doc = new Dom.Document();
          doc.load(response);
          //Retrieve the root element for this document.
        Dom.XMLNode ordDtls = doc.getRootElement();
         //Dom.XmlNode dataitemvalues= ordDtls.getChildElement('dataItemValues','http://www.axeda.com/services/v2').getchildElement('dataItemValue','http://www.axeda.com/services/v2');
         Dom.XmlNode dataitemvalues= ordDtls.getChildElement('dataItemValues','http://www.axeda.com/services/v2');
            //String dataitemvalue = ordDtls.getChildElement('dataItemValue', 'http://www.axeda.com/services/v2').getText();
        // print out specific elements
  
        //for( Asset myobject : myobjects)
        for( List <Asset> myobject : [ select Id from Asset where Id In ('02i54000000DdVJAA0','02i54000000DdVKAA0','02i54000000DdVRAA0','02i54000000DdViAAK','02i54000000DdW4AAK')])
        {
            for(dom.XmlNode node : dataitemvalues.getChildElements())
            { 
             for(Integer i = 0;i<myobject.size();i++)
             {
        System.debug('dataitemvalues: ' + dataitemvalues);
        System.debug('dataitemvalues children' + dataitemvalues.getChildren());
        System.debug('size is'+myobject.size());        
            //for(dom.XmlNode node : dataitemvalues.getChildElements())//commented on 04192016
            //for(dom.Xmlnode node:dataitemvalues.getChildren())
            //{
              //for(Integer i = 0;i<node;i++) 
                if (node.getName() == 'dataItemValue')
                {
                String name =  node.getChildElement('dataItem','http://www.axeda.com/services/v2').getChildElement('name','http://www.axeda.com/services/v2').getText();  
                System.debug('name is'+name);
                    if ((name == 'FBackThigh') || (name == 'FFlank') || (name == 'FLowerAbdomen') || (name== 'FOther') || (name == 'FOtherAnatomy') || (name == 'FUpperAbdomen') || (name == 'MaleChests') || (name == 'MBackShoulder') || (name == 'MBackThigh') || (name == 'MCalves') || (name == 'MChest') || (name == 'MFlank') ||
                    (name == 'MLowerAbdomen') || (name == 'MOther') || (name == 'MOtherAnatomy') || (name == 'MUpperAbdomen') || (name =='SN') || (name == 'CalculationExpression') || (name  == 'FBackShoulder'))
                {
                   }
                else
                {
                   if (name == 'Age')
                   {
                     System.debug('inside if loop');
                     System.debug('value of i is'+i); 
                     //List<String> Agevalue = new List<String>(); 
                     String Agevalue;
                     Map<Integer, String> m = new Map<Integer, String>();
                     List<String> Agevalues = new List<String>(); 
                     //Agevalue.add(node.getChildElement('value','http://www.axeda.com/services/v2').getText());
                     Agevalue = node.getChildElement('value','http://www.axeda.com/services/v2').getText();
                     m.put(1,Agevalue);                      
                     System.debug('node child elemenode child element Agent Agenode child element Age value value'+Agevalue);
                     System.debug('map get value is'+m.get(1));
                     System.debug('map keyset is'+m.values());
                     Agevalues = m.values();
                     System.debug('Age Values are'+Agevalues); 
                     //for (String values : Agevalues) 
                     //{   
                     //myobjects[i].Age_Range__c = m.get(1);
                     myobject[i].Age_Range__c = Agevalue;
                     //update myobject; 
                     System.debug('Age Range is'+myobject[i].Age_Range__c);
                     //System.debug('age range index values are'+Agevalues[i]);   
                     //update myobject;   
                     //}  
                     //update myobject; 
                     //myobjects[i].Age_Range__c =  Agevalue;
                     if (myobjects.size()> 0)
                    {
                       //for(Integer i = 0;i<myobjects.size() - 1;i++) 
                       //{
                        //myobject.Age_Range__c = AgeValue;
                        //if (i < myobjects.size() - 1){
                        try
                        {   
                         //myobjects[i].Age_Range__c =  Agevalue.get(i);
                        }
                        catch(Exception e)
                        {
                          System.debug('Error Message is'+e); 
                        } 
                       // }
                        //System.debug('Age value is'+myobjects[i].Age_Range__c);
                     }
                                   
                     //}
                       
                     //update myobjects[i]; 
                   }
                         
                     
                     //System.debug('node child element value'+Agevalue); 
                    }//end of else
                   
       } //end of if
                    //update myobject;
                    //System.debug('node child element name'+name);
                     } //end of inner for loop
                      System.debug('My Object is'+myobject);
                       update myobject;//commnted this line on 04192016
                       //update myobjects[i];
                       //update myobjects;
                     } //end of for loop i
                    } //end of outer for loop
                     System.debug('My Objects are'+myobjects);
                    //myobjects.update(myobject);
                    //update myobjects;
           }
          catch(System.DMLException e) { 
           //Exception handling goes here....
           System.debug('error message is'+e);
          
        }
        System.debug('response is'+response);
       //return response;
     
        }
   
Hi
I have an visualforce page which calls custom controller.A method getIFrameSrc gets the ifRame URL.That URL i have to pass it to visualforce page <apex:iframe>.I am able to pass it.But i am getting a blank page.
VF Page Code
<apex:page sidebar="false"  controller="CXiIntercept3">
<!--action="{!getIFrameSrc}">-->
<!--showHeader="false"-->
<!--<apex:stylesheet value="{!URLFOR($Resource.paymetricsCSS, 'paymetricsCSS.css')}"/>-->
  <apex:form >
  <!--<apex:actionFunction name="getIFrameSrc" action="{!getIFrameSrc}" rerender="out" status="myStatus"/>-->
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="cache-control" content="no-cache, no-store, max-age=0, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <title>XiIntercept v3 - Implementation Demo</title>
    <script type="text/javascript">
<form id="form1">
   
        <div>
            <p>This sample shows the basic functionality of implementing the iframe solution.</p>
            <!--<iframe id="IFrame" name="dieCommFrame" frameBorder="0" src="http://www.w3schools.com"></iframe>-->
            <apex:iframe id="dieCommFrame" frameborder="0" src="{!getIFrameSrc}"/>
             <!--<apex:commandButton value="Load" action="{!getIFrameSrc}"/>-->
              <!--<apex:commandLink action="{!getIFrameSrc}" value="Load" id="theCommandLink"/>-->
            <!--<apex:param name="strSrcURL"
                value="{!getIFrameSrc}"
                assignTo="{!getIFrameSrc}"/>-->
        <!--</apex:commandButton>-->
                    </div>
        <div>
            <p />
            <table>
                <thead>
                    <tr>
                        <th colspan="2">Billing Address</th>
                    </tr>               
                </thead>
                <tbody>
                    <tr>
                        <td class="Column1">Name</td>
                        <td class="Column2">
                        <input id="Text1" type="text" value="John Doe" size="32" /></td>
                        <!--<apex:InputField label="Name" id="Text1" value="John Doe"/>-->
                    </tr>
                    <tr>
                        <td class="Column1">Address</td>
                        <td class="Column2"><input id="Text2" type="text" value="19500 State Hwy 249" size="32" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">City</td>
                        <td class="Column2"><input id="Text3" type="text" value="Houston" size="32" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">State</td>
                        <td class="Column2"><input id="Text4" type="text" value="Texas" size="16" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">Zip Code</td>
                        <td class="Column2"><input id="Text5" type="text" value="77070" size="8" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">&nbsp;</td>
                        <td class="Column2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="Column1">&nbsp;</td>
                        <td class="Column2">
                              <!--<apex:commandButton id="cmdPayment" action="{!submitForm}" value="Tokenize Data"/>-->
                         <input id="cmdPayment" type="button" onclick="submitForm(); return false;" value="Tokenize Data" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </form>
       </body>
       </apex:form>
    </apex:page>
Apex Class Code is given below
public with sharing class CXiIntercept3
{

   /*public CXiIntercept3(ApexPages.StandardController controller) {
       m_strURL = 'https://qaapp02.xisecurenet.com/diecomm';
        m_strGUID = '8842aa98-d6d1-40a4-9ee0-c02a3393b7af' ;
        m_strPSK = '4Kb/=5ZkrX{7_3HcTt8+!Md6C2$e9}aJ' ;
        getIFrameSrc();
    }*/


    public String getIFrameSrc { get;
    set
    {
        System.debug('Inside IFrameSrc');
        String strWhere = 'getIFrameSrc';
        //alert('getIFrameSrc');
        System.debug('strWhere is'+strWhere);
        String strAccessToken = getIFrameAccessToken();
       
        String strSrcURL = m_strURL + '/view/iframe/' + m_strGUID + '/' + strAccessToken + '/true';
       
        Log(strWhere, 'IFrameSrc', strSrcURL);
        System.debug('iFrame URL is'+strSrcURL);
        getIFrameSrc = strSrcURL;
        System.debug('getIFrameSRc is'+getIFrameSrc);
        //return strSrcURL;
     }
    }
    public PageReference submitForm() {
        /*pageReference acctPage = new PageReference('https://cynosure--slqa--c.cs19.visual.force.com/apex/Paymetrics_Page');
    acctPage.setRedirect(true);*/
        return null ;    }

    public String m_strURL;
    public String m_strGUID;
    public String m_strPSK;
       
    public CXiIntercept3()
    {
        m_strURL = 'https://qaapp02.xisecurenet.com/diecomm';
        m_strGUID = '8842aa98-d6d1-40a4-9ee0-c02a3393b7af' ;
        m_strPSK = '4Kb/=5ZkrX{7_3HcTt8+!Md6C2$e9}aJ' ;
        getIFrameSrc();
      }

    public String getIFrameSrc()
    {
        System.debug('Inside IFrameSrc');
        String strWhere = 'getIFrameSrc';
        //alert('getIFrameSrc');
        System.debug('strWhere is'+strWhere);
        String strAccessToken = getIFrameAccessToken();
       
        String strSrcURL = m_strURL + '/view/iframe/' + m_strGUID + '/' + strAccessToken + '/true';
       
        Log(strWhere, 'IFrameSrc', strSrcURL);
        System.debug('iFrame URL is'+strSrcURL);
       
        return strSrcURL;
    }
   
    public String getIFrameAccessToken()
    {
        String strAT = '';
        String strResponse = '';
        String strURL = m_strURL + '/AccessToken';
        String strWhere = 'getSignedXML';
        StaticResource static_resource = [Select Body From StaticResource Where Name = 'Paymetrics_CSS'];
        String strXml = static_resource.body.toString();
        System.debug('strxml is'+strxml);
        //String strXml = '';
        //String strXml = getIFrameMerchantHTML();
        String strSignature = '';
       
        Dom.Document hDoc = null;
        Dom.XmlNode hRoot = null;
        Dom.XmlNode hResponse = null;
        Dom.XmlNode hAT = null;
        System.debug('packet ' + EncodingUtil.urlEncode(strXml, 'UTF-8'));
        String strPostXml = 'MerchantGuid=' + m_strGUID + '&' +
                    'SessionRequestType=1&' +
                    'Packet=' + EncodingUtil.urlEncode(strXml, 'UTF-8') + '&' +
                    'Signature=' + EncodingUtil.urlEncode(getDigitalSignature(strXml), 'UTF-8') + '&' +
                    'MerchantDevelopmentEnvironment=SalesForce';
        System.debug('strPostxml is ' +strPostXml);
        //System.debug('packet ' + EncodingUtil.urlEncode(strXml, 'UTF-8'));
        //Log(strWhere, 'strXml', strXml);
        //Log(strWhere, 'strPostXml', strPostXml);
        //Log(strWhere, 'strSignature', strSignature);
       
        hDoc = executeHttpRequest(strURL, strPostXml, 'POST');
        hRoot = hDoc.getRootElement();
        if(hRoot != null)
        {
            hResponse = hRoot.getChildElement('ResponsePacket', null);
            if(hResponse != null)
            {
                hAT = hResponse.getChildElement('AccessToken', null);
                if(hAT != null)
                    strAT = hAT.getText();
            }
        }
        Log(strWhere, 'AccessToken', strAT);
        System.debug('Access Token is'+strAT);
       
        return strAT;
    }
   
    public String getXmlRequest()
    {
        String strWhere = 'getXmlRequest';
        //String strRedirect = getRequestUrl();
        String strRedirect = '';
        String xmlRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
       

        //strRedirect = strRedirect.replace('XiIntercept3RQ', 'XiIntercept3RS');
        xmlRequest += '<PostPacketModel><RedirectUri>' + strRedirect + '</RedirectUri></PostPacketModel>';
       
        Log(strWhere, 'strRedirect', strRedirect);
        Log(strWhere, 'xmlRequest', xmlRequest);
       
        return xmlRequest;
    }
   
    /*public String getIFrameMerchantHTML()
    {
        /* code snippet to retrieve merchant xml into string */
        /*
            String strURL = '' + Site.getBaseUrl();
       
            if(strURL.length() == 0)
            {
                strURL = URL.getCurrentRequestUrl().toExternalForm().replace('XiIntercept3RQ', 'XiIntercept3RS');
            }
            else strURL += '/XiIntercept3RS';
           
           
           
            String xmlRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
        */
   // }
   
    private void Log(String strWhere, String strName, String strValue)
    {
        System.debug(strWhere + '() - ' + strName + ' => ' + strValue);
    }

    private String getDigitalSignature(String strData)
    {
        String strWhere = 'getDigitalSignature';
        String strSignature = '';
       
        strSignature = EncodingUtil.base64Encode(Crypto.generateMac('hmacSHA256', Blob.valueOf(strData), Blob.valueOf(m_strPSK)));
        System.debug('strsignature is'+strsignature);
        Log(strWhere, 'strData', strData);
        Log(strWhere, 'strSignature', strSignature);
       
        return strSignature;
    }

    private Dom.Document getResponsePacket(String strAccessToken)
    {
        String strWhere = 'getResponsePacket';
        String strSignature = getDigitalSignature(strAccessToken);
        String strUrlParams = m_strURL + '/ResponsePacket';
        Dom.Document hDoc = null;
       
        strUrlParams += '?MerchantGUID=' + m_strGUID;
        strUrlParams += '&Signature=' + EncodingUtil.urlEncode(strSignature, 'UTF-8');
        strUrlParams += '&AccessToken=' + strAccessToken;
       
        Log(strWhere, 'strUrlParams', strUrlParams);
        hDoc = executeHttpRequest(strUrlParams, '', 'GET');
        Log(strWhere, 'hDoc.toXmlString()', hDoc.toXmlString());
       
        return hDoc;
    }
   
    private Dom.Document executeHttpRequest(String targetURL, String urlParameters, String requestType)
    {
        String strWhere = 'executeHttpRequest';
        Dom.Document hDoc = null;
        Http myHttp = new Http();
        HttpRequest httpRQ = new HttpRequest();
        HttpResponse httpRS = null;
       
        Log(strWhere, 'targetURL', targetURL);
        Log(strWhere, 'requestType', requestType);
        Log(strWhere, 'urlParameters', urlParameters);
       
        httpRQ.setEndpoint(targetURL);
        httpRQ.setMethod(requestType);
        if(requestType.equalsIgnoreCase('POST'))
        {
            httpRQ.setHeader('Content-Type', 'application/x-www-form-urlencoded');
            httpRQ.setHeader('Content-Length', String.valueOf(urlParameters.Length()));
            httpRQ.setHeader('Content-Language', 'en-US');
            httpRQ.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
            httpRQ.setHeader('Pragma', 'no-cache');
            httpRQ.setBody(urlParameters);
        }
       
        httpRS = myHttp.send(httpRQ);
        if(httpRS != null)
        {
            Log(strWhere, 'httpRS.getBody()', httpRS.getBody());
            hDoc = httpRS.getBodyDocument();
        }
        else
        {
            hDoc = new Dom.Document();
        }
       
        return hDoc;
    }
}
Any suggestions are welcome..
Thanks
Sricharan
 
I am calling a web service,getting response and updating mutiple asset records in Salesforce.Response XML is given below

In the XML we have multiple values for Age.First Age value must be stored in first asset record and so on.Issue is last value of Age in the xml is stored is getting stored for all Asset Records.
My Apex class code is given below.
global class AxedaDataItemBatch1 implements Database.Batchable<sObject>,Database.AllowsCallouts{
Public String query;

String email;

Id toUserId;

Id fromUserId;
    global Database.querylocator start(Database.BatchableContext BC)
    {
       //String query = 'Select Id from Asset where SerialNumber = 'SCLP0003'';          
            return Database.getQueryLocator(query);
    }
global void execute(Database.BatchableContext BC, List<sObject> scope){

        //List<Asset> myobjects = [ select Id from Asset where SerialNumber = 'SCLP0007' ];
        List<Asset> myobjects = [ select Id from Asset where Id In ('02i54000000DdVJAA0','02i54000000DdVKAA0','02i54000000DdVRAA0','02i54000000DdViAAK','02i54000000DdW4AAK')];
       
       
        AxedaSession asp = new AxedaSession();
        String SessionId = asp.SessionId();
        System.debug('session id'+SessionId);
       
        HttpRequest req = new HttpRequest();
        HTTPResponse res;
        String AssetId = '2381';
        //Set HTTPRequest Method 
        req.setMethod('POST');
       
        //String password = 'Cynosure793*';
        //System.debug('password is'+password);
      
        //Blob headerValue = Blob.valueOf(username + ':' + password); */
      
        //String authorizationHeader = 'NTLM ' + EncodingUtil.base64Encode(headerValue);
        //String authorizationHeader = 'NTLM ' + headerValue; 
        //System.debug('authorization header is'+authorizationHeader);
 
        //req.setEndpoint('https://cynosure.axeda.com/services/v2/rest/dataItem/findCurrentValues');
        req.setEndpoint('https://cynosure.axeda.com/services/v2/rest/dataItem/findHistoricalValues');   
        //req.setEndpoint('http://www.webservicex.com/stockquote.asmx');
        req.setMethod('POST');
        //req.setMethod('findByCriteria');
        //req.setHeader('Content-Type', 'text/xml; charset=UTF-8');
        req.setHeader('Content-Type', 'application/xml');
        //req.setHeader('Content-Type', 'charset=UTF-8');
        //req.setHeader('Content-Type','application/json');
        req.setHeader('x_axeda_wss_sessionid',SessionId);
        //req.setHeader('sessionId', MySessionID);
        //req.setHeader('Authorization', authorizationHeader);  
        //req.setHeader('SOAPAction', 'http://devwdapps.cynosure.com/XiPayWSConnector/XiPayWSConnector.XiPay.svc');
        //req.setHeader('SOAPAction','http://Primesys/XiPaySoap/message/IXiPay/Authorize');
        /*string b =   '<?xml version="1.0" encoding="UTF-8"?><v2:CurrentDataItemValueCriteria xmlns:v2="http://www.axeda.com/services/v2"'+
            ' xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" sortAscending="true" sortPropertyName="Name">'+
                      '<v2:name>*</v2:name><v2:assetId>'+AssetId+'</v2:assetId>'+
                       '<v2:types/></v2:CurrentDataItemValueCriteria>';*/
        string b =   '<?xml version="1.0" encoding="UTF-8"?><v2:HistoricalDataItemValueCriteria xmlns:v2="http://www.axeda.com/services/v2"'+
            ' xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" sortAscending="true" sortPropertyName="Name">'+
                      '<v2:assetId>'+AssetId+'</v2:assetId>'+
                       '<v2:dataItemIds/></v2:HistoricalDataItemValueCriteria>';   
        req.setBody(b);
        System.debug('b is'+b);
        System.debug('request is'+req);
        Http http = new Http();
        String response;
        try { 
          //Execute web service call here        
          res = http.send(req); 
          response = res.getBody();
          System.debug(res.toString());
          System.debug(res.getBody());
          System.debug('response is'+response);
          Dom.Document doc = new Dom.Document();
          doc.load(response);
          //Retrieve the root element for this document.
        Dom.XMLNode ordDtls = doc.getRootElement();
         //Dom.XmlNode dataitemvalues= ordDtls.getChildElement('dataItemValues','http://www.axeda.com/services/v2').getchildElement('dataItemValue','http://www.axeda.com/services/v2');
         Dom.XmlNode dataitemvalues= ordDtls.getChildElement('dataItemValues','http://www.axeda.com/services/v2');
            //String dataitemvalue = ordDtls.getChildElement('dataItemValue', 'http://www.axeda.com/services/v2').getText();
        // print out specific elements
  
        //for( Asset myobject : myobjects)
        for( List <Asset> myobject : [ select Id from Asset where Id In ('02i54000000DdVJAA0','02i54000000DdVKAA0','02i54000000DdVRAA0','02i54000000DdViAAK','02i54000000DdW4AAK')])
        {
            for(dom.XmlNode node : dataitemvalues.getChildElements())
            { 
             for(Integer i = 0;i<myobject.size();i++)
             {
        System.debug('dataitemvalues: ' + dataitemvalues);
        System.debug('dataitemvalues children' + dataitemvalues.getChildren());
        System.debug('size is'+myobject.size());        
            //for(dom.XmlNode node : dataitemvalues.getChildElements())//commented on 04192016
            //for(dom.Xmlnode node:dataitemvalues.getChildren())
            //{
              //for(Integer i = 0;i<node;i++) 
                if (node.getName() == 'dataItemValue')
                {
                String name =  node.getChildElement('dataItem','http://www.axeda.com/services/v2').getChildElement('name','http://www.axeda.com/services/v2').getText();  
                System.debug('name is'+name);
                    if ((name == 'FBackThigh') || (name == 'FFlank') || (name == 'FLowerAbdomen') || (name== 'FOther') || (name == 'FOtherAnatomy') || (name == 'FUpperAbdomen') || (name == 'MaleChests') || (name == 'MBackShoulder') || (name == 'MBackThigh') || (name == 'MCalves') || (name == 'MChest') || (name == 'MFlank') ||
                    (name == 'MLowerAbdomen') || (name == 'MOther') || (name == 'MOtherAnatomy') || (name == 'MUpperAbdomen') || (name =='SN') || (name == 'CalculationExpression') || (name  == 'FBackShoulder'))
                {
                   }
                else
                {
                   if (name == 'Age')
                   {
                     System.debug('inside if loop');
                     System.debug('value of i is'+i); 
                     //List<String> Agevalue = new List<String>(); 
                     String Agevalue;
                     Map<Integer, String> m = new Map<Integer, String>();
                     List<String> Agevalues = new List<String>(); 
                     //Agevalue.add(node.getChildElement('value','http://www.axeda.com/services/v2').getText());
                     Agevalue = node.getChildElement('value','http://www.axeda.com/services/v2').getText();
                     m.put(1,Agevalue);                      
                     System.debug('node child elemenode child element Agent Agenode child element Age value value'+Agevalue);
                     System.debug('map get value is'+m.get(1));
                     System.debug('map keyset is'+m.values());
                     Agevalues = m.values();
                     System.debug('Age Values are'+Agevalues); 
                     //for (String values : Agevalues) 
                     //{   
                     //myobjects[i].Age_Range__c = m.get(1);
                     myobject[i].Age_Range__c = Agevalue;
                     //update myobject; 
                     System.debug('Age Range is'+myobject[i].Age_Range__c);
                     //System.debug('age range index values are'+Agevalues[i]);   
                     //update myobject;   
                     //}  
                     //update myobject; 
                     //myobjects[i].Age_Range__c =  Agevalue;
                     if (myobjects.size()> 0)
                    {
                       //for(Integer i = 0;i<myobjects.size() - 1;i++) 
                       //{
                        //myobject.Age_Range__c = AgeValue;
                        //if (i < myobjects.size() - 1){
                        try
                        {   
                         //myobjects[i].Age_Range__c =  Agevalue.get(i);
                        }
                        catch(Exception e)
                        {
                          System.debug('Error Message is'+e); 
                        } 
                       // }
                        //System.debug('Age value is'+myobjects[i].Age_Range__c);
                     }
                                   
                     //}
                       
                     //update myobjects[i]; 
                   }
                         
                     
                     //System.debug('node child element value'+Agevalue); 
                    }//end of else
                   
       } //end of if
                    //update myobject;
                    //System.debug('node child element name'+name);
                     } //end of inner for loop
                      System.debug('My Object is'+myobject);
                       update myobject;//commnted this line on 04192016
                       //update myobjects[i];
                       //update myobjects;
                     } //end of for loop i
                    } //end of outer for loop
                     System.debug('My Objects are'+myobjects);
                    //myobjects.update(myobject);
                    //update myobjects;
           }
          catch(System.DMLException e) { 
           //Exception handling goes here....
           System.debug('error message is'+e);
          
        }
        System.debug('response is'+response);
       //return response;
     
        }
   
Hi
I have an visualforce page which calls custom controller.A method getIFrameSrc gets the ifRame URL.That URL i have to pass it to visualforce page <apex:iframe>.I am able to pass it.But i am getting a blank page.
VF Page Code
<apex:page sidebar="false"  controller="CXiIntercept3">
<!--action="{!getIFrameSrc}">-->
<!--showHeader="false"-->
<!--<apex:stylesheet value="{!URLFOR($Resource.paymetricsCSS, 'paymetricsCSS.css')}"/>-->
  <apex:form >
  <!--<apex:actionFunction name="getIFrameSrc" action="{!getIFrameSrc}" rerender="out" status="myStatus"/>-->
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="cache-control" content="no-cache, no-store, max-age=0, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <title>XiIntercept v3 - Implementation Demo</title>
    <script type="text/javascript">
<form id="form1">
   
        <div>
            <p>This sample shows the basic functionality of implementing the iframe solution.</p>
            <!--<iframe id="IFrame" name="dieCommFrame" frameBorder="0" src="http://www.w3schools.com"></iframe>-->
            <apex:iframe id="dieCommFrame" frameborder="0" src="{!getIFrameSrc}"/>
             <!--<apex:commandButton value="Load" action="{!getIFrameSrc}"/>-->
              <!--<apex:commandLink action="{!getIFrameSrc}" value="Load" id="theCommandLink"/>-->
            <!--<apex:param name="strSrcURL"
                value="{!getIFrameSrc}"
                assignTo="{!getIFrameSrc}"/>-->
        <!--</apex:commandButton>-->
                    </div>
        <div>
            <p />
            <table>
                <thead>
                    <tr>
                        <th colspan="2">Billing Address</th>
                    </tr>               
                </thead>
                <tbody>
                    <tr>
                        <td class="Column1">Name</td>
                        <td class="Column2">
                        <input id="Text1" type="text" value="John Doe" size="32" /></td>
                        <!--<apex:InputField label="Name" id="Text1" value="John Doe"/>-->
                    </tr>
                    <tr>
                        <td class="Column1">Address</td>
                        <td class="Column2"><input id="Text2" type="text" value="19500 State Hwy 249" size="32" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">City</td>
                        <td class="Column2"><input id="Text3" type="text" value="Houston" size="32" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">State</td>
                        <td class="Column2"><input id="Text4" type="text" value="Texas" size="16" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">Zip Code</td>
                        <td class="Column2"><input id="Text5" type="text" value="77070" size="8" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">&nbsp;</td>
                        <td class="Column2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="Column1">&nbsp;</td>
                        <td class="Column2">
                              <!--<apex:commandButton id="cmdPayment" action="{!submitForm}" value="Tokenize Data"/>-->
                         <input id="cmdPayment" type="button" onclick="submitForm(); return false;" value="Tokenize Data" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </form>
       </body>
       </apex:form>
    </apex:page>
Apex Class Code is given below
public with sharing class CXiIntercept3
{

   /*public CXiIntercept3(ApexPages.StandardController controller) {
       m_strURL = 'https://qaapp02.xisecurenet.com/diecomm';
        m_strGUID = '8842aa98-d6d1-40a4-9ee0-c02a3393b7af' ;
        m_strPSK = '4Kb/=5ZkrX{7_3HcTt8+!Md6C2$e9}aJ' ;
        getIFrameSrc();
    }*/


    public String getIFrameSrc { get;
    set
    {
        System.debug('Inside IFrameSrc');
        String strWhere = 'getIFrameSrc';
        //alert('getIFrameSrc');
        System.debug('strWhere is'+strWhere);
        String strAccessToken = getIFrameAccessToken();
       
        String strSrcURL = m_strURL + '/view/iframe/' + m_strGUID + '/' + strAccessToken + '/true';
       
        Log(strWhere, 'IFrameSrc', strSrcURL);
        System.debug('iFrame URL is'+strSrcURL);
        getIFrameSrc = strSrcURL;
        System.debug('getIFrameSRc is'+getIFrameSrc);
        //return strSrcURL;
     }
    }
    public PageReference submitForm() {
        /*pageReference acctPage = new PageReference('https://cynosure--slqa--c.cs19.visual.force.com/apex/Paymetrics_Page');
    acctPage.setRedirect(true);*/
        return null ;    }

    public String m_strURL;
    public String m_strGUID;
    public String m_strPSK;
       
    public CXiIntercept3()
    {
        m_strURL = 'https://qaapp02.xisecurenet.com/diecomm';
        m_strGUID = '8842aa98-d6d1-40a4-9ee0-c02a3393b7af' ;
        m_strPSK = '4Kb/=5ZkrX{7_3HcTt8+!Md6C2$e9}aJ' ;
        getIFrameSrc();
      }

    public String getIFrameSrc()
    {
        System.debug('Inside IFrameSrc');
        String strWhere = 'getIFrameSrc';
        //alert('getIFrameSrc');
        System.debug('strWhere is'+strWhere);
        String strAccessToken = getIFrameAccessToken();
       
        String strSrcURL = m_strURL + '/view/iframe/' + m_strGUID + '/' + strAccessToken + '/true';
       
        Log(strWhere, 'IFrameSrc', strSrcURL);
        System.debug('iFrame URL is'+strSrcURL);
       
        return strSrcURL;
    }
   
    public String getIFrameAccessToken()
    {
        String strAT = '';
        String strResponse = '';
        String strURL = m_strURL + '/AccessToken';
        String strWhere = 'getSignedXML';
        StaticResource static_resource = [Select Body From StaticResource Where Name = 'Paymetrics_CSS'];
        String strXml = static_resource.body.toString();
        System.debug('strxml is'+strxml);
        //String strXml = '';
        //String strXml = getIFrameMerchantHTML();
        String strSignature = '';
       
        Dom.Document hDoc = null;
        Dom.XmlNode hRoot = null;
        Dom.XmlNode hResponse = null;
        Dom.XmlNode hAT = null;
        System.debug('packet ' + EncodingUtil.urlEncode(strXml, 'UTF-8'));
        String strPostXml = 'MerchantGuid=' + m_strGUID + '&' +
                    'SessionRequestType=1&' +
                    'Packet=' + EncodingUtil.urlEncode(strXml, 'UTF-8') + '&' +
                    'Signature=' + EncodingUtil.urlEncode(getDigitalSignature(strXml), 'UTF-8') + '&' +
                    'MerchantDevelopmentEnvironment=SalesForce';
        System.debug('strPostxml is ' +strPostXml);
        //System.debug('packet ' + EncodingUtil.urlEncode(strXml, 'UTF-8'));
        //Log(strWhere, 'strXml', strXml);
        //Log(strWhere, 'strPostXml', strPostXml);
        //Log(strWhere, 'strSignature', strSignature);
       
        hDoc = executeHttpRequest(strURL, strPostXml, 'POST');
        hRoot = hDoc.getRootElement();
        if(hRoot != null)
        {
            hResponse = hRoot.getChildElement('ResponsePacket', null);
            if(hResponse != null)
            {
                hAT = hResponse.getChildElement('AccessToken', null);
                if(hAT != null)
                    strAT = hAT.getText();
            }
        }
        Log(strWhere, 'AccessToken', strAT);
        System.debug('Access Token is'+strAT);
       
        return strAT;
    }
   
    public String getXmlRequest()
    {
        String strWhere = 'getXmlRequest';
        //String strRedirect = getRequestUrl();
        String strRedirect = '';
        String xmlRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
       

        //strRedirect = strRedirect.replace('XiIntercept3RQ', 'XiIntercept3RS');
        xmlRequest += '<PostPacketModel><RedirectUri>' + strRedirect + '</RedirectUri></PostPacketModel>';
       
        Log(strWhere, 'strRedirect', strRedirect);
        Log(strWhere, 'xmlRequest', xmlRequest);
       
        return xmlRequest;
    }
   
    /*public String getIFrameMerchantHTML()
    {
        /* code snippet to retrieve merchant xml into string */
        /*
            String strURL = '' + Site.getBaseUrl();
       
            if(strURL.length() == 0)
            {
                strURL = URL.getCurrentRequestUrl().toExternalForm().replace('XiIntercept3RQ', 'XiIntercept3RS');
            }
            else strURL += '/XiIntercept3RS';
           
           
           
            String xmlRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
        */
   // }
   
    private void Log(String strWhere, String strName, String strValue)
    {
        System.debug(strWhere + '() - ' + strName + ' => ' + strValue);
    }

    private String getDigitalSignature(String strData)
    {
        String strWhere = 'getDigitalSignature';
        String strSignature = '';
       
        strSignature = EncodingUtil.base64Encode(Crypto.generateMac('hmacSHA256', Blob.valueOf(strData), Blob.valueOf(m_strPSK)));
        System.debug('strsignature is'+strsignature);
        Log(strWhere, 'strData', strData);
        Log(strWhere, 'strSignature', strSignature);
       
        return strSignature;
    }

    private Dom.Document getResponsePacket(String strAccessToken)
    {
        String strWhere = 'getResponsePacket';
        String strSignature = getDigitalSignature(strAccessToken);
        String strUrlParams = m_strURL + '/ResponsePacket';
        Dom.Document hDoc = null;
       
        strUrlParams += '?MerchantGUID=' + m_strGUID;
        strUrlParams += '&Signature=' + EncodingUtil.urlEncode(strSignature, 'UTF-8');
        strUrlParams += '&AccessToken=' + strAccessToken;
       
        Log(strWhere, 'strUrlParams', strUrlParams);
        hDoc = executeHttpRequest(strUrlParams, '', 'GET');
        Log(strWhere, 'hDoc.toXmlString()', hDoc.toXmlString());
       
        return hDoc;
    }
   
    private Dom.Document executeHttpRequest(String targetURL, String urlParameters, String requestType)
    {
        String strWhere = 'executeHttpRequest';
        Dom.Document hDoc = null;
        Http myHttp = new Http();
        HttpRequest httpRQ = new HttpRequest();
        HttpResponse httpRS = null;
       
        Log(strWhere, 'targetURL', targetURL);
        Log(strWhere, 'requestType', requestType);
        Log(strWhere, 'urlParameters', urlParameters);
       
        httpRQ.setEndpoint(targetURL);
        httpRQ.setMethod(requestType);
        if(requestType.equalsIgnoreCase('POST'))
        {
            httpRQ.setHeader('Content-Type', 'application/x-www-form-urlencoded');
            httpRQ.setHeader('Content-Length', String.valueOf(urlParameters.Length()));
            httpRQ.setHeader('Content-Language', 'en-US');
            httpRQ.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
            httpRQ.setHeader('Pragma', 'no-cache');
            httpRQ.setBody(urlParameters);
        }
       
        httpRS = myHttp.send(httpRQ);
        if(httpRS != null)
        {
            Log(strWhere, 'httpRS.getBody()', httpRS.getBody());
            hDoc = httpRS.getBodyDocument();
        }
        else
        {
            hDoc = new Dom.Document();
        }
       
        return hDoc;
    }
}
Any suggestions are welcome..
Thanks
Sricharan