Solved

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

Posted on 2008-06-24
8
420 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:Shruthi_123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 21857887

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/
0
 

Author Comment

by:Shruthi_123
ID: 21876233
I have tried this. I`m not able to extract content from CFHTTP.file content. This is not workinga dn i`m getting error
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 21876293
You tried the CFC ?

what error are you getting?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 21876307
since you are creating the XML yourself, perhaps you should validate it to ensure its a good format..

Use an on-line tool like this one, or any other you find googling "XML validator"
http://www.validome.org/xml/
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 22025973
please read the instructions about grading.  
http://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.  

0
 

Author Closing Comment

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

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question