Link to home
Start Free TrialLog in
Avatar of Shruthi_123
Shruthi_123

asked on

How do i get values from CFHTTP.filecontent. PLEASE HELP!!!!!!!!

I have 3 CFM pages. I am using CFHTTP POST method.This is used for displaying the member results when we search a member
PAGE 1: This is used for creating an XML
PAGE 2: This is used for invoking the method
PAGE3: This is used for displaying the results.
PAGE  1 and PAGE 2 are placed in a seperate folder inside wwwroot(web root) folder of C:. PAGE 3 is placed in a seperate folder. I am sending a HTTP request from PAGE 3 to PAGE 1.
I want to display the values like first name,last name etc.. from the CFHTTP.filecontent.
I am getting the file content only when  i put a dump in PAGE 2
<CFOUTPUT><CFDUMP var=""/></CFOUTPUT>

PAGE 1: This is used for creating an XML
<CFFUNCTION name="createSiebelXML" access="public" output="false" returntype="any">
                        <CFARGUMENT name="nameFirst" type="string" required="No" default=""/>
                        <CFARGUMENT name="nameLast" type="string" required="No" default=""/>
                        <CFARGUMENT name="state" type="string" required="No" default=""/>
                        <CFARGUMENT name="organization" type="string" required="No" default=""/>
                        <CFARGUMENT name="zip" type="string" required="No" default=""/>
                        <CFSCRIPT>
                                    var objcreateSiebelXML = XMLNew();
                        </CFSCRIPT>
                        <CFQUERY name="qrySiebelSelect" datasource="edgeGoldmanSachs">
                                    SELECT
                                                distinct m.memberid,
                                                m.nameFirst,
                                                m.nameMiddle,
                                                m.nameLast,
                                                m.email,
                                                m.memberNumber,
                                                m.dynamicRecordID,
                                                m.organization,
                                                m.salutation,
                                                b.memberTypeName,
                                                a.address1,
                                                a.address2,
                                                a.address3,
                                                a.city,
                                                a.stprId,
                                                s.stateCode,
                                                a.addressname,
                                                a.country,
                                                a.postalcode,
                                                a.phonework,
                                                a.addresstypeId,
                                                a.addressObjTypeId
                                    FROM
                                                members m
                                                            LEFT OUTER JOIN addresses a  ON m.memberID = a.memberID
                                                            LEFT OUTER JOIN edgeMaster.dbo.stateProv s ON isnull(a.stprId,0) = s.stprId
                                                            INNER JOIN memberTypes b ON            m.memberTypeId = b.memberTypeId
                                    WHERE 0=0
                                                            <CFIF arguments.nameFirst NEQ "">
                                                                        AND m.nameFirst LIKE '#arguments.nameFirst#%'
                                                            </CFIF>
                                                            <CFIF arguments.nameLast NEQ "">
                                                                        AND m.nameLast LIKE '#arguments.nameLast#%'
                                                            </CFIF>
                                                            <CFIF arguments.organization NEQ "">
                                                                        AND m.organization LIKE '#arguments.organization#%'
                                                            </CFIF>
                                                            <CFIF arguments.state NEQ "">
                                                                        AND s.stateCode = '#arguments.state#'
                                                            </CFIF>
                                                            <CFIF arguments.postalcode NEQ "">
                                                                        AND a.postalcode = '#arguments.postalcode#'
                                                            </CFIF>
                                                                        AND m.statusID NOT IN (SELECT
                                                                                                                                                StatusID
                                                                                                                           FROM
                                                                                                                                                edgeMaster..STATUS
                                                                                                                           WHERE
                                                                                                                                                StatusCode = <CFQUERYPARAM cfsqltype="CF_SQL_VARCHAR" value="deleted" />
                                                                                                                                                OR StatusCode = <CFQUERYPARAM cfsqltype="CF_SQL_VARCHAR" value="inactive" />)
                                                            ORDER BY m.nameFirst
                        </CFQUERY>
                        <CFQUERY name="qryAddresstypesSelect" datasource="edgeGoldmanSachs">
                                    SELECT
                                                addresstypeId,
                                                addressObjTypeId,
                                                addressName,
                                                nameFirst,
                                                nameMiddle,
                                                nameLast,
                                                salutation,
                                                organization,
                                                address1,
                                                address2,
                                                address3,
                                                city,
                                                stprID,
                                                postalCode,
                                                countryID,
                                                phoneWork,
                                                fax,
                                                phoneHome,
                                                phoneCell,
                                                phoneOther,
                                                phonePager,
                                                email
                                    FROM
                                                addresses
                                    WHERE
                                                memberId =  <CFQUERYPARAM value="#qrySiebelSelect.memberId#" cfsqltype="cf_sql_any"/> AND
                                                primaryForType = 1
                        </CFQUERY>
                        <CFQUERY name="qryAddressUsageTypeSelect" datasource="edgeMaster">
                                    SELECT
                                                addressObjName
                                    FROM
                                                addressObjType
                                    WHERE
                                                addressObjTypeId = <CFQUERYPARAM value="#qryAddresstypesSelect.addressObjTypeId#" cfsqltype="cf_sql_any"/>
                        </CFQUERY>
                        <CFQUERY name="qryAddressTypeSelect" datasource="edgeGoldmanSachs">
                                    SELECT
                                                addressTypeName
                                    FROM
                                                addressTypes
                                    WHERE
                                                addressTypeId = <CFQUERYPARAM value="#qryAddresstypesSelect.addresstypeId#" cfsqltype="cf_sql_any"/>
                        </CFQUERY>
                        <CFIF qryAddresstypesSelect.recordcount NEQ 0>
                                    <CFSCRIPT>
                                                objcreateSiebelXML.XMLRoot = XmlElemNew(objcreateSiebelXML,"","PAYLOAD");
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.XMLChildren, XmlElemNew(objcreateSiebelXML,"","SEARCHRESULT"));
                                                objcreateSiebelXML.XMLRoot.SEARCHRESULT.XmlText = "#qryAddresstypesSelect.recordcount#";
                                                for(intCount = 1; intCount LE qryAddresstypesSelect.recordcount; intCount=intCount+1)
                                                {//Members
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.XMLChildren, XmlElemNew(objcreateSiebelXML,"","MEMBER"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML,"","CONTACTID"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "SALUTATION"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "FIRSTNAME"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "MIDDLEINITIAL"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "LASTNAME"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "MEMBERTYPE"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "ORGANIZATION"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "FIRMNUMBER"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "EMAILADDRESS"));
                                                //Addresses
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.XMLChildren, XmlElemNew(objcreateSiebelXML,"","ADDRESSES"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.XMLChildren, XmlElemNew(objcreateSiebelXML,"","ADDRESS"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML,"","ADDRESSNAME"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "ADDRESSUSAGETYPE"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "PRIMARYUSAGETYPE"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "ADDRESSTYPE"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "FIRSTNAME"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "LASTNAME"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "ORGANIZATION"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "ADDRESSLINE1"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "ADDRESSLINE2"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML,"","ADDRESSLINE3"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "CITY"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "STATE"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "POSTALCODE"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "COUNTRY"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "WORKPHONENUMBER"));
                                                ArrayAppend(objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.XMLChildren, XmlElemNew(objcreateSiebelXML, "", "EMAILADDRESS"));
                                                //member values
                                                objcreateSiebelXML.XMLRoot.MEMBER.CONTACTID.XmlText = "#trim(qrySiebelSelect.memberId[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.FIRSTNAME[intCount].XmlText = "#trim(qrySiebelSelect.nameFirst[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.MIDDLEINITIAL[intCount].XmlText = "#trim(qrySiebelSelect.nameMiddle[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.LASTNAME[intCount].XmlText = "#trim(qrySiebelSelect.nameLast[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.MEMBERTYPE[intCount].XmlText = "#trim(qrySiebelSelect.memberTypeName[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ORGANIZATION[intCount].XmlText = "#trim(qrySiebelSelect.organization[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.FIRMNUMBER[intCount].XmlText = "#trim(qrySiebelSelect.dynamicRecordID[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.EMAILADDRESS[intCount].XmlText = "#trim(qrySiebelSelect.email[intCount])#";
                                                //address values
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ADDRESSNAME.XmlText = "#trim(qryAddresstypesSelect.addressname[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ADDRESSUSAGETYPE[intCount].XmlText = "#trim(qryAddressUsageTypeSelect.addressObjName[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.PRIMARYUSAGETYPE[intCount].XmlText = "#trim(qrySiebelSelect.addressname[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ADDRESSTYPE[intCount].XmlText = "#trim(qryAddressTypeSelect.addressTypeName[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.FIRSTNAME[intCount].XmlText = "#trim(qrySiebelSelect.nameFirst[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.LASTNAME[intCount].XmlText = "#trim(qrySiebelSelect.nameLast[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ORGANIZATION[intCount].XmlText = "#trim(qrySiebelSelect.organization[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ADDRESSLINE1[intCount].XmlText = "#trim(qrySiebelSelect.address1[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ADDRESSLINE2.XmlText = "#trim(qrySiebelSelect.address2[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.ADDRESSLINE3[intCount].XmlText = "#trim(qrySiebelSelect.address3[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.CITY[intCount].XmlText = "#trim(qrySiebelSelect.city[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.STATE[intCount].XmlText = "#trim(qrySiebelSelect.stateCode[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.POSTALCODE[intCount].XmlText = "#trim(qrySiebelSelect.postalcode[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.COUNTRY[intCount].XmlText = "#trim(qrySiebelSelect.country[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.WORKPHONENUMBER[intCount].XmlText = "#trim(qrySiebelSelect.phonework[intCount])#";
                                                objcreateSiebelXML.XMLRoot.MEMBER.ADDRESSES.ADDRESS.EMAILADDRESS[intCount].XmlText = "#trim(qrySiebelSelect.email[intCount])#";
                                                }
                                    </CFSCRIPT>
                        </CFIF>
                        <CFRETURN objcreateSiebelXML/>
            </CFFUNCTION>

PAGE 2: This is used for invoking the method
<CFINVOKE component = "Siebel" method = "createSiebelXML" returnvariable = "objcreateSiebelXML">
            <CFINVOKEARGUMENT name="nameFirst" value="#form.Firstname#"/>
            <CFINVOKEARGUMENT name="nameLast" value="#form.Lastname#"/>
            <CFINVOKEARGUMENT name="organization" value="#form.Organization#"/>
            <CFINVOKEARGUMENT name="stateCode" value="#form.State#"/>
            <CFINVOKEARGUMENT name="postalcode" value="#form.Zip#"/>
</CFINVOKE>
            <CFSET Siebel = 'Siebel' & '_' & dateformat(now(),'YYYYMMDD') & timeformat(now(),'HHMMSS')/>
            <CFFILE action="write" file="C:\Inetpub\wwwroot\Siebel\#Siebel#.xml" output="#toString(objcreateSiebelXML)#"/>
            <CFOBJECT action="create" type="java" class="com.twmacinta.util.EncryptWBase64MD5" name="objBase64">
            <CFOBJECT action="create" type="java" class="org.apache.xerces.utils.Base64" name="objBase">
            <CFSET Hashcode=objBase64.getMD5HashCode(tostring(objcreateSiebelXML))>
            <CFSET varEncPayload=objBase64.EncryptPayload(tostring(objcreateSiebelXML),0)>
            <CFSET varHashCode = objBase.encode(Hashcode.getBytes())>
            <input type="hidden" name="test" value="1"/>

PAGE3: This is used for displaying the results.

<SCRIPT language="javascript1.2">
            function test()
            {
                        document.searchCriteria.hdnLocal.value = 1;
                        document.searchCriteria.hdnnameFirst.value = document.searchCriteria.nameFirst.value;
                        document.searchCriteria.hdnnameLast.value = document.searchCriteria.nameLast.value;
                        document.searchCriteria.hdnOrganization.value = document.searchCriteria.organization.value;
                        document.searchCriteria.hdnState.value = document.searchCriteria.state.value;
                        document.searchCriteria.hdnZip.value = document.searchCriteria.zip.value;
                        document.searchCriteria.submit();


            }
</SCRIPT>

<CFIF ISDEFINED("hdnLocal")>

            <CFHTTP method="post" url="http://localhost/Siebel/dspSiebel.cfm">
                        <CFHTTPPARAM type="formfield" name="projectId" value="17">
                        <CFHTTPPARAM type="formfield" name="Firstname" value="#hdnnameFirst#">
                        <CFHTTPPARAM type="formfield" name="Lastname" value="#hdnnameLast#">
                        <CFHTTPPARAM type="formfield" name="Organization" value="#hdnOrganization#">
                        <CFHTTPPARAM type="formfield" name="State" value="#hdnState#">
                        <CFHTTPPARAM type="formfield" name="Zip" value="#hdnZip#">
            </CFHTTP>
            <CFDUMp var="#cfhttp.FileContent#"/>
</CFIF>

I am not able seperate values from the cfhttp.FileContent
PLEASE TELL me how to retrieve seperate values like First name,last name (refer XML PART in PAGE 1) from the cfhttp.FileContent. I want to display first name,last name etc.... in the PAGE 3
PLEASE tell me a solution to display the results in PAGE 3 from  PAGE 2.

PLS REPLY SOON
Avatar of gdemaria
gdemaria
Flag of United States of America image


assuming you have read in valid XML from your CFHTTP, you can then parse it using

 <cfset theXML = XMLparse(cfhttp.FileContent)

 Then dump theXML and you can access the various nodes like they were structure.

 Here's nice little tool that may make it even easier.  Download this function and call it with your fileContent, it will return a structure, then you can just use CF to walk through the structure...

  http://www.anujgakhar.com/2007/11/05/coldfusion-xml-to-struct/
Avatar of Shruthi_123
Shruthi_123

ASKER

I have tried this. I`m not able to extract content from CFHTTP.file content. This is not workinga dn i`m getting error
You tried the CFC ?

what error are you getting?
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
please read the instructions about grading.  
https://www.experts-exchange.com/help.jsp#hi97

Giving someone a "C" is a black mark.   I would rather you close the question with no points than give me a C, unless of course, I deserve it.

I'm glad you solved your own problem, but you have to close this question based on it's own merits.   Did I provide you with good accurate infromation?  Did I leave you hanging?  If I provided no relevant infromation and you solved it own your own, then you can close the question without giving any points.    If I provided you good information, but you needed more, you should ask for it.  

Ypur comments are usefull but i soved this in a different way using encryption decryption method. Thanks for ur solution. Please close my question