[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating query from XML Soap Call

Posted on 2012-08-20
11
Medium Priority
?
437 Views
Last Modified: 2012-08-21
I am looping through an array that is generated from an xml soap call. When I output the query, the first one is not what I expect, but the rest of them are what I would expect.  It is suppose to output the name value for each row, but on the first query, the array is displaying the same name value for every row.

Here are links to see what I am talking about.  The first one shows the dump of the query, the second one shows the dump of the array and the query.



Code for the xml call:
<!---************************************************************************************************--->
<!---***************************************    IMPORTANT    ****************************************--->
<!---***         This file is not used for the Hotels. See stay-details.cfm for hotel file        ***--->
<!---************************************************************************************************--->

<!---Get the UserName and Password for the soap call from the idss table--->
<cfquery datasource="#DataSource#" name="getIDSSLogin">
	SELECT UserName, Password
    FROM idss
    WHERE ID = 1
</cfquery>

<cfif IsDefined("Form.MemberID")>
	<cfset MemberID = Form.MemberID>
</cfif>
<cfif IsDefined("URL.MemberID")>
	<cfset MemberID = URL.MemberID>
</cfif>
<cfif IsDefined("getCouponToEdit.MemberID")>
	<cfset MemberID = getCouponToEdit.MemberID>
</cfif>
<cfif IsDefined("getCoupon.MemberID")>
	<cfset MemberID = getCoupon.MemberID>
</cfif>

<cfif IsDefined("URL.CategoryID")>
    <cfquery datasource="#DataSource#" name="getVenueDefID">
        SELECT VenueDefID
        FROM categories
        WHERE CategoryID = <cfqueryparam value="#URL.CategoryID#" cfsqltype="cf_sql_integer">
    </cfquery>
    <cfset VenueDefID = getVenueDefID.VenueDefID>
</cfif>

<!---Used when VenueDefID is passed through the friendly url--->
<cfif IsDefined("URL.VenueDefID")>
    <cfset VenueDefID = URL.VenueDefID>
</cfif>

<!---Used on the Search Result Details page--->
<cfif IsDefined("URL.SearchIDSSID")>
	<cfquery datasource="#DataSource#" name="getVenueDefID">
        SELECT VenueDefID
        From categories
        WHERE IDSSCatID = <cfqueryparam value="#URL.SearchIDSSID#" cfsqltype="cf_sql_integer">
    </cfquery>
    <cfset VenueDefID = getVenueDefID.VenueDefID>
</cfif>

<cfsavecontent variable="GetVenueByMemberBody">
	<cfoutput>
        <?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
          <soap:Header>
            <AuthorizeHeader xmlns="http://ws.idssasp.com/venue.asmx"><br />
              <UserName>#getIDSSLogin.UserName#</UserName>
              <Password>#getIDSSLogin.Password#</Password>
            </AuthorizeHeader>
          </soap:Header>
          <soap:Body>
            <GetVenueByMember xmlns="http://ws.idssasp.com/venue.asmx">
              <memberID>#MemberID#</memberID>
              <venueDefID>63</venueDefID>
              <includeAddresses>true</includeAddresses>
              <includeSpaces>false</includeSpaces>
              <includeConfigs>false</includeConfigs>
              <includeAttributes>true</includeAttributes>
              <includeSpaceAttributes>true</includeSpaceAttributes>
            </GetVenueByMember>
          </soap:Body>
        </soap:Envelope>
    </cfoutput>
</cfsavecontent>

<!---Turn the soap call into something ColdFusion can use--->
<cfhttp
	url="http://ws.idssasp.com/venue.asmx"
	method="post"
	result="httpResponse">
    <cfhttpparam
        type="header"
        name="SOAPAction"
        value="http://ws.idssasp.com/venue.asmx/GetVenueByMember"
        />
    <cfhttpparam
        type="header"
        name="accept-encoding"
        value="no-compression"
        />
    <cfhttpparam
		type="xml"
		value="#trim( GetVenueByMemberBody )#"
		/>
</cfhttp>

<!--- Parse the XML SOAP response. --->
<cfset GetVenueByMemberParsed = xmlParse( httpResponse.fileContent ) />


<!---<h1>Soap Call:</h1>
<p>MemberID: <cfoutput>#MemberID#</cfoutput></p>
<p>VenueDefID: <cfoutput>#getVenueDefID.VenueDefID#</cfoutput></p>
<cfdump var="#GetVenueByMemberParsed#">
<cfabort>
--->

<!---Venue Details - pulls address and other info from Venues--->
<cfset VenueDetails = GetVenueByMemberParsed["soap:Envelope"]["soap:Body"]["GetVenueByMemberResponse"]["GetVenueByMemberResult"]>
<!---<cfdump var="#VenueDetails#">--->

<cfset getVenueDetails = QueryNew("VenueName, AccountID, Phone, SecondaryPhone, Fax, Website, VenueComments, VenueCommentsHtml, Street, Suite, Address3, Address4, City, StateAbbr, PostalCode, GoogleMapQuery")>

<cfloop array="#VenueDetails#" index="VenueAccountNode">
	<cfset VenueName	 		= TRIM(VenueAccountNode["VenueName"].xmlText)>
    <cfset VenueComments  	= TRIM(VenueAccountNode["VenueComments"].xmlText)>
    <cfset VenueCommentsHtml  	= TRIM(VenueAccountNode["VenueCommentsHtml"].xmlText)>
	<cfset AccountID    		= TRIM(VenueAccountNode["VenueAccount"]["AccountID"].xmlText)>
    <cfset Phone 	  			= TRIM(VenueAccountNode["VenueAccount"]["Phone"].xmlText)>
    <cfset SecondaryPhone 		= TRIM(VenueAccountNode["VenueAccount"]["SecondaryPhone"].xmlText)>
    <cfset Fax 	  				= TRIM(VenueAccountNode["VenueAccount"]["Fax"].xmlText)>
    <cfset Website 	  			= TRIM(VenueAccountNode["VenueAccount"]["Website"].xmlText)>
    <cfset Street 	  			= TRIM(VenueAccountNode["VenueAddress"]["Street"].xmlText)>
    <cfset Suite 	  			= TRIM(VenueAccountNode["VenueAddress"]["Suite"].xmlText)>
    <cfset Address3 	  		= TRIM(VenueAccountNode["VenueAddress"]["Address3"].xmlText)>
    <cfset Address4 	  		= TRIM(VenueAccountNode["VenueAddress"]["Address4"].xmlText)>
    <cfset City 	  			= TRIM(VenueAccountNode["VenueAddress"]["City"].xmlText)>
    <cfset StateAbbr 	  		= TRIM(VenueAccountNode["VenueAddress"]["StateAbbr"].xmlText)>
    <cfset PostalCode 	  		= TRIM(VenueAccountNode["VenueAddress"]["PostalCode"].xmlText)>
    <cfset GoogleMapQuery 		= TRIM(VenueAccountNode["VenueAddress"]["GoogleMapQuery"].xmlText)>
    
    <cfset row = queryAddRow(getVenueDetails, 1)>
		<cfset getVenueDetails.VenueName[row] = VenueName>
    	<cfset getVenueDetails.AccountID[row] = AccountID>
		<cfset getVenueDetails.Phone[row] = Phone>
		<cfset getVenueDetails.SecondaryPhone[row] = SecondaryPhone>
		<cfset getVenueDetails.Fax[row] = Fax>
		<cfset getVenueDetails.Website[row] = Website>
		<cfset getVenueDetails.VenueComments[row] = VenueComments>
		<cfset getVenueDetails.VenueCommentsHtml[row] = VenueCommentsHtml>
		<cfset getVenueDetails.Street[row] = Street>
		<cfset getVenueDetails.Suite[row] = Suite>
		<cfset getVenueDetails.Address3[row] = Address3>
		<cfset getVenueDetails.Address4[row] = Address4>
		<cfset getVenueDetails.City[row] = City>
		<cfset getVenueDetails.StateAbbr[row] = StateAbbr>
		<cfset getVenueDetails.PostalCode[row] = PostalCode>
		<cfset getVenueDetails.GoogleMapQuery[row] = GoogleMapQuery>
</cfloop>

<!---Create a query from the XML--->
<cfset attributes = GetVenueByMemberParsed["soap:Envelope"]["soap:Body"]["GetVenueByMemberResponse"]["GetVenueByMemberResult"]["Attributes"].XmlChildren>

<cfset getMemberDetails = QueryNew("Logo, LogoTitle, LogoAlt, Photo, PhotoTitle, PhotoAlt, Keywords, EnhancedFile")>
<cfset getAttributes = QueryNew("Name, DisplayName, Type, Value")>

<cfloop array="#attributes#" index="AttributeNode">
        <cfset name       	= trim(AttributeNode["Name"].xmlText)>
		<cfset displayname  = trim(AttributeNode["DisplayName"].xmlText)>
		<cfset type     	= AttributeNode["Type"].xmlText>
		<cfset value     	= AttributeNode["Value"].xmlText>
        
        <cfif type eq "boolean" and value eq 1>
			<cfset includeAttribute = true>
		<cfelseif type eq "string" and len(value)>
			<cfset includeAttribute = true>
		<cfelse>
			<cfset includeAttribute = false>
		</cfif>	
        	
		<cfset excludeAttributes = "list"> 
        <!--- if it's in the exclude list above, set includeAttribute = false --->
		<cfif includeAttribute> 
            <cfset attributeName = name>
             <cfset includeAttribute = NOT listFindNoCase(excludeAttributes , attributeName)>
        </cfif>
        
		<cfif includeAttribute>
				<cfset row = queryAddRow(getAttributes, 1)>
                <cfset getAttributes.DisplayName[row] = displayname>
                <cfset getAttributes.Type[row] = type>
                <cfset getAttributes.Value[row] = value>
                <cfset getAttributes.Name[row] = name>
		</cfif>
</cfloop>

Open in new window


Any ideas why this would produce a different query dump on the first one? If I put in a single value for MemberID and view just the code for the call and query it shows that one record fine.
0
Comment
Question by:lonnyo
  • 7
  • 4
11 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 38313053
Is the 2nd link correct? I'm getting a 404 error when I try and view it..
0
 

Author Comment

by:lonnyo
ID: 38313229
Sorry, thought I uploaded it.  It is working now.  Takes a little longer to load because of the xml dump.

Thanks
Lonny Olson
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38313256
Yeah my brower's choking with all the data cfdump generates.  Can you just dump the original XML *string*?  Then I can parse it and test your code locally :)

         #HTMLEditFormat( httpResponse.fileContent )#
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:lonnyo
ID: 38313596
I think everything you need is below.  I stripped out the stuff you don't need and put the username and password in the code for the xml call (I was calling them from my database).

It is now repeating the same value for the "Name" field on all the queries.  I am very confused!

XML Call to loop through the member (Note: I don't have issues with this call, but you will need it to loop through the members list).

<!---Get the UserName and Password for the soap call from the idss table--->
<!---<cfquery datasource="#DataSource#" name="getIDSSLogin">
	SELECT UserName, Password
    FROM idss
    WHERE ID = 1
</cfquery>
--->
<!---Call the data using soap. The ISSSCatID that matches the category is stored in the categories table--->
<cfsavecontent variable="C134_GetMembersByCategoryBody">
	<cfoutput>
		<?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
        <AuthorizeHeader xmlns="http://ws.idssasp.com/Members.asmx">
        <UserName>burnsville</UserName>
                <Password>618b86b9-6ea0-421d-b4e4-a755619a5f53</Password>
        </AuthorizeHeader>
        </soap:Header>
        <soap:Body>
          <C134_GetMembersByCategory xmlns="http://ws.idssasp.com/Members.asmx">
            <categoryIDs>3504</categoryIDs>
            <includeChildCategories>false</includeChildCategories>
            <includeAddresses>true</includeAddresses>
            <venueDefID>63</venueDefID>
          </C134_GetMembersByCategory>
        </soap:Body>
       
        </soap:Envelope>
	</cfoutput>
</cfsavecontent>
<!---Turn the soap call into something ColdFusion can use--->
<cfhttp
	url="http://ws.idssasp.com/Members.asmx"
	method="post"
	result="httpResponse">
    <cfhttpparam
        type="header"
        name="SOAPAction"
        value="http://ws.idssasp.com/Members.asmx/C134_GetMembersByCategory"
        />
    <cfhttpparam
        type="header"
        name="accept-encoding"
        value="no-compression"
        />
    <cfhttpparam
		type="xml"
		value="#trim( C134_GetMembersByCategoryBody )#"
		/>
</cfhttp>

<!--- Parse the XML SOAP response. --->
<cfset C134_GetMembersByCategoryBody = xmlParse( httpResponse.fileContent ) />
<!---Set the Parsed XML equal to an array variable that can be used to create a query--->
<cfset MembersByCategory = C134_GetMembersByCategoryBody["soap:Envelope"]["soap:Body"]["C134_GetMembersByCategoryResponse"]["C134_GetMembersByCategoryResult"].XmlChildren>

<!---<cfdump var="#MembersByCategory#">
--->
<!---Create a query from the XML--->
<cfset getMembersByCategory = QueryNew("MemberID, AccountName, Phone, SecondaryPhone, Website, Street, Suite, Address3, Address4, City, StateAbbr, PostalCode, GoogleMapQuery, ID, ParentID, Name, SortOrder, DescriptionHtml")>
<!---Loop through the XML Array to create the rows and columns in the query--->
<cfloop FROM="1" TO="#arrayLen(MembersByCategory)#" index="i">
	<cfset memberValues = "">
	<cfset memberValues = MembersByCategory[i].XmlChildren>
    <!---Make sure the Node exists. If not, the field will have an empty string.--->
	<cftry>
    <cfset addressValues = "">
    <cfset addressValues = MembersByCategory[i]["Addresses"]["Address"].XmlChildren>
    <cfcatch type="expression"></cfcatch></cftry>
    <!---Make sure the Node exists. If not, the field will have an empty string.--->
    <cftry>
    <cfset categoryValues = "">
    <cfset categoryValues = MembersByCategory[i]["Categories"]["MemberCategory134"].XmlChildren>
	<cfcatch type="expression"></cfcatch></cftry>
    <!---Make sure the Node exists. If not, the field will have an empty string.--->
    <cftry>
    <cfset directoryValues = "">
    <cfset directoryValues = MembersByCategory[i]["Categories"]["MemberCategory134"]["Directories"]["MemberDirectory"].XmlChildren>
	<cfcatch type="expression"></cfcatch></cftry>
    
	<cfset queryAddRow(getMembersByCategory)>
	<cfset querySetCell(getMembersByCategory, "MemberID", memberValues[1]["XmlText"])>
	<cfset querySetCell(getMembersByCategory, "AccountName", memberValues[2]["XmlText"])>
	<cfset querySetCell(getMembersByCategory, "Phone", memberValues[3]["XmlText"])> 
	<cfset querySetCell(getMembersByCategory, "SecondaryPhone", memberValues[4]["XmlText"])>
	<cfset querySetCell(getMembersByCategory, "Website", memberValues[6]["XmlText"])>
    <!---Make sure the Node exists. If not, the field will have an empty string.--->
	<cftry> 
		<cfset querySetCell(getMembersByCategory, "Street", addressValues[2]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "Suite", addressValues[3]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "Address3", addressValues[4]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "Address4", addressValues[5]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "City", addressValues[6]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "StateAbbr", addressValues[8]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "PostalCode", addressValues[9]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "GoogleMapQuery", addressValues[12]["XmlText"])>
    <cfcatch type="expression"></cfcatch>
    </cftry>
    <!---Make sure the Node exists. If not, the field will have an empty string.--->
    
    
    
    <!---*****************************************************************************--->
    <!---Need to loop through this node to get the Name where the ParentID equals 3504--->
    <cftry>
		<cfset querySetCell(getMembersByCategory, "ID", categoryValues[1]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "ParentID", categoryValues[2]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "Name", categoryValues[3]["XmlText"])>
        <cfset querySetCell(getMembersByCategory, "SortOrder", categoryValues[5]["XmlText"])>
    <cfcatch type="expression"></cfcatch>
    </cftry>
    <!---*****************************************************************************--->
    
    
    
    <!---Make sure the Node exists. If not, the field will have an empty string.--->
    <cftry>
    	<cfset querySetCell(getMembersByCategory, "DescriptionHtml", directoryValues[5]["XmlText"])>
    <cfcatch type="expression"></cfcatch>
    </cftry>
</cfloop>

<cfif IsDefined("URL.MemberID")>
	<!---The variable in where statement is a URL variable because of friendly url (orginates as form variable)--->
    <cfquery dbtype="query" name="QofQMember">
        SELECT MemberID, AccountName, Phone, SecondaryPhone, Website, Street, Suite, Address3, Address4, City, StateAbbr, PostalCode, GoogleMapQuery, DescriptionHtml
        FROM getMembersByCategory
        WHERE MemberID = <cfqueryparam value="#URL.MemberID#" cfsqltype="cf_sql_integer">
    </cfquery>
</cfif>

<cfif IsDefined("URL.searchValue")>
	<cfset URL.searchValue = Replace(LCase(URL.searchValue), "'", "''", "all")> 
</cfif>
<cfquery dbtype="query" name="QofQMembers">
    SELECT MemberID, AccountName, Phone, SecondaryPhone, Website, Street, Suite, Address3, Address4, City, StateAbbr, PostalCode, GoogleMapQuery, ID, ParentID, Name, SortOrder, DescriptionHtml
    FROM getMembersByCategory
    <cfif IsDefined("URL.searchValue")>
        WHERE LOWER(AccountName) LIKE <cfqueryparam value="%#URL.searchValue#%" cfsqltype="cf_sql_varchar">
        OR LOWER(DescriptionHtml) LIKE <cfqueryparam value="%#URL.searchValue#%" cfsqltype="cf_sql_longvarchar"> 
    </cfif>
    ORDER BY AccountName ASC
</cfquery>

<!---<cfdump var="#QofQMembers#">
<cfdump var="#MembersByCategory#">--->

Open in new window


XML Call that I am having issues with:
<cfsavecontent variable="GetVenueByMemberBody">
	<cfoutput>
        <?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
          <soap:Header>
            <AuthorizeHeader xmlns="http://ws.idssasp.com/venue.asmx"><br />
              <UserName>burnsville</UserName>
              <Password>618b86b9-6ea0-421d-b4e4-a755619a5f53</Password>
            </AuthorizeHeader>
          </soap:Header>
          <soap:Body>
            <GetVenueByMember xmlns="http://ws.idssasp.com/venue.asmx">
              <memberID>#MemberID#</memberID>
              <venueDefID>63</venueDefID>
              <includeAddresses>true</includeAddresses>
              <includeSpaces>false</includeSpaces>
              <includeConfigs>false</includeConfigs>
              <includeAttributes>true</includeAttributes>
              <includeSpaceAttributes>true</includeSpaceAttributes>
            </GetVenueByMember>
          </soap:Body>
        </soap:Envelope>
    </cfoutput>
</cfsavecontent>

<!---Turn the soap call into something ColdFusion can use--->
<cfhttp
	url="http://ws.idssasp.com/venue.asmx"
	method="post"
	result="httpResponse">
    <cfhttpparam
        type="header"
        name="SOAPAction"
        value="http://ws.idssasp.com/venue.asmx/GetVenueByMember"
        />
    <cfhttpparam
        type="header"
        name="accept-encoding"
        value="no-compression"
        />
    <cfhttpparam
		type="xml"
		value="#trim( GetVenueByMemberBody )#"
		/>
</cfhttp>

<!--- Parse the XML SOAP response. --->
<cfset GetVenueByMemberParsed = xmlParse( httpResponse.fileContent ) />


<!---<h1>Soap Call:</h1>
<p>MemberID: <cfoutput>#MemberID#</cfoutput></p>
<p>VenueDefID: <cfoutput>#getVenueDefID.VenueDefID#</cfoutput></p>
<cfdump var="#GetVenueByMemberParsed#">
<cfabort>
--->

<!---Venue Details - pulls address and other info from Venues--->
<cfset VenueDetails = GetVenueByMemberParsed["soap:Envelope"]["soap:Body"]["GetVenueByMemberResponse"]["GetVenueByMemberResult"]>
<!---<cfdump var="#VenueDetails#">--->

<cfset getVenueDetails = QueryNew("VenueName, AccountID, Phone, SecondaryPhone, Fax, Website, VenueComments, VenueCommentsHtml, Street, Suite, Address3, Address4, City, StateAbbr, PostalCode, GoogleMapQuery")>

<cfloop array="#VenueDetails#" index="VenueAccountNode">
	<cfset VenueName	 		= TRIM(VenueAccountNode["VenueName"].xmlText)>
    <cfset VenueComments  	= TRIM(VenueAccountNode["VenueComments"].xmlText)>
    <cfset VenueCommentsHtml  	= TRIM(VenueAccountNode["VenueCommentsHtml"].xmlText)>
	<cfset AccountID    		= TRIM(VenueAccountNode["VenueAccount"]["AccountID"].xmlText)>
    <cfset Phone 	  			= TRIM(VenueAccountNode["VenueAccount"]["Phone"].xmlText)>
    <cfset SecondaryPhone 		= TRIM(VenueAccountNode["VenueAccount"]["SecondaryPhone"].xmlText)>
    <cfset Fax 	  				= TRIM(VenueAccountNode["VenueAccount"]["Fax"].xmlText)>
    <cfset Website 	  			= TRIM(VenueAccountNode["VenueAccount"]["Website"].xmlText)>
    <cfset Street 	  			= TRIM(VenueAccountNode["VenueAddress"]["Street"].xmlText)>
    <cfset Suite 	  			= TRIM(VenueAccountNode["VenueAddress"]["Suite"].xmlText)>
    <cfset Address3 	  		= TRIM(VenueAccountNode["VenueAddress"]["Address3"].xmlText)>
    <cfset Address4 	  		= TRIM(VenueAccountNode["VenueAddress"]["Address4"].xmlText)>
    <cfset City 	  			= TRIM(VenueAccountNode["VenueAddress"]["City"].xmlText)>
    <cfset StateAbbr 	  		= TRIM(VenueAccountNode["VenueAddress"]["StateAbbr"].xmlText)>
    <cfset PostalCode 	  		= TRIM(VenueAccountNode["VenueAddress"]["PostalCode"].xmlText)>
    <cfset GoogleMapQuery 		= TRIM(VenueAccountNode["VenueAddress"]["GoogleMapQuery"].xmlText)>
    
    <cfset row = queryAddRow(getVenueDetails, 1)>
		<cfset getVenueDetails.VenueName[row] = VenueName>
    	<cfset getVenueDetails.AccountID[row] = AccountID>
		<cfset getVenueDetails.Phone[row] = Phone>
		<cfset getVenueDetails.SecondaryPhone[row] = SecondaryPhone>
		<cfset getVenueDetails.Fax[row] = Fax>
		<cfset getVenueDetails.Website[row] = Website>
		<cfset getVenueDetails.VenueComments[row] = VenueComments>
		<cfset getVenueDetails.VenueCommentsHtml[row] = VenueCommentsHtml>
		<cfset getVenueDetails.Street[row] = Street>
		<cfset getVenueDetails.Suite[row] = Suite>
		<cfset getVenueDetails.Address3[row] = Address3>
		<cfset getVenueDetails.Address4[row] = Address4>
		<cfset getVenueDetails.City[row] = City>
		<cfset getVenueDetails.StateAbbr[row] = StateAbbr>
		<cfset getVenueDetails.PostalCode[row] = PostalCode>
		<cfset getVenueDetails.GoogleMapQuery[row] = GoogleMapQuery>
</cfloop>

<!---Create a query from the XML--->
<cfset attributes = GetVenueByMemberParsed["soap:Envelope"]["soap:Body"]["GetVenueByMemberResponse"]["GetVenueByMemberResult"]["Attributes"].XmlChildren>

<cfset getMemberDetails = QueryNew("Logo, LogoTitle, LogoAlt, Photo, PhotoTitle, PhotoAlt, Keywords, EnhancedFile")>
<cfset getAttributes = QueryNew("Name, DisplayName, Type, Value")>

<cfloop array="#attributes#" index="AttributeNode">
        <cfset name       	= trim(AttributeNode["Name"].xmlText)>
		<cfset displayname  = trim(AttributeNode["DisplayName"].xmlText)>
		<cfset type     	= AttributeNode["Type"].xmlText>
		<cfset value     	= AttributeNode["Value"].xmlText>
        
        <cfif type eq "boolean" and value eq 1>
			<cfset includeAttribute = true>
		<cfelseif type eq "string" and len(value)>
			<cfset includeAttribute = true>
		<cfelse>
			<cfset includeAttribute = false>
		</cfif>	
        	
		<cfset excludeAttributes = "list"> 
        <!--- if it's in the exclude list above, set includeAttribute = false --->
		<cfif includeAttribute> 
            <cfset attributeName = name>
             <cfset includeAttribute = NOT listFindNoCase(excludeAttributes , attributeName)>
        </cfif>
        
		<cfif includeAttribute>
				<cfset row = queryAddRow(getAttributes, 1)>
                <cfset getAttributes.DisplayName[row] = displayname>
                <cfset getAttributes.Type[row] = type>
                <cfset getAttributes.Value[row] = value>
                <cfset getAttributes.Name[row] = name>
		</cfif>
</cfloop>

Open in new window


Output of data:

<!---I loop through QofQMembers in idss-queries/meeting-rooms.cfm to get the list of members--->
<!---NOTE: MemberID is derived from this query--->
<cfinclude template="idss-queries/meeting-rooms.cfm">


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>

            <h1 class="category-name">Meeting Venues</h1>
            <cfif QofQMembers.RecordCount>
            
            <cfoutput query="QofQMembers">
            	<!---Get the venue information for each record--->
            	<cfinclude template="idss-queries/meet-venue-details.cfm">
                <h2 class="floatLeft">#getVenueDetails.VenueName# (#AccountID#)</h2>
                <!---<cfdump var="#getVenueDetails#">--->
                <cfdump var="#getAttributes#">
            </cfoutput>
            <cfelse>
            <p>Sorry, no records were found.</p>
            </cfif>

</body>
</html>

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 38313719
Thanks, but I think that codes needs a #memberID# value to run? I didn't see one above.

Actually all I'm looking for is the raw result of the cfhttp call. It's just a big soap xml string.  I don't know if you saw my earlier comment) but here's how to output it again:

       .. do the cfhttp call ...
      <cfoutput>#HTMLEditFormat(   httpResponse.fileContent )# </cfoutput>
0
 

Author Comment

by:lonnyo
ID: 38313814
It comes from the first call.  If you place the first two files in a directory called idss-queries (sorry forgot to mention that) and then preview the output code, it will pull both soap calls (they are setup as includes in the output file). Each time it loops through my query from the first soap call it will pass the MemberID to the second call.  I gave you all the code so you can dump whatever you need to see.

Sorry this is such a pain.  I appreciate the help.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38314156
Sorry, my bad.  (I thought it'd be easier to just post the xml string so anyone could copy / paste and parse it). But I've got the cfhttp call running now thanks,  so let me take a look.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38314218
Hm... I think it may be a variable scoping clash due to the way the files are included.  Because the results are different when you run the file outside the query output loop.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 38314251
Yeah, it's definitely a variable scoping clash.  

It's a weird subtlety of query loops.  Some of the query columns from #QofQMembers# have the same names as the variables you're using inside the included template "meet-venue-details.cfm" (like "name", "type", etc...).  So when you do this:

                 <cfset name = trim(AttributeNode["Name"].xmlText)>
              ....
                 <cfset getAttributes.Name[row] = Name>

CF uses the "name" from the parent query #QofQMembers# and NOT the value from your xml node. That's why the values seem like they're repeating.  

To fix the problem either use different variable names  OR scope the variables (better).

                    Use                       <cfset variables.name = "...">
                    instead of just    <cfset name = "...">

Really all variables should be scoped. Below I just scoped the key variables to demo the fix:

.... 
<!---Create a query from the XML--->
<cfset attributes = GetVenueByMemberParsed["soap:Envelope"]["soap:Body"]["GetVenueByMemberResponse"]["GetVenueByMemberResult"]["Attributes"].XmlChildren>

<cfset getMemberDetails = QueryNew("Logo, LogoTitle, LogoAlt, Photo, PhotoTitle, PhotoAlt, Keywords, EnhancedFile")>
<cfset getAttributes = QueryNew("Name, DisplayName, Type, Value")>

<cfloop array="#attributes#" index="AttributeNode">
                <!--- MUST scope the variables to avoid conflicts --->
                <cfset variables.Name       	= trim(AttributeNode["Name"].xmlText)>
		<cfset variables.Displayname  = trim(AttributeNode["DisplayName"].xmlText)>
		<cfset variables.Type     	= AttributeNode["Type"].xmlText>
		<cfset variables.Value     	= AttributeNode["Value"].xmlText>
        
        <cfif variables.Type eq "boolean" and variables.Value eq 1>
			<cfset includeAttribute = true>
		<cfelseif variables.Type eq "string" and len(variables.Value)>
			<cfset includeAttribute = true>
		<cfelse>
			<cfset includeAttribute = false>
		</cfif>	
        	
		<cfset excludeAttributes = "list"> 
        <!--- if it's in the exclude list above, set includeAttribute = false --->
		<cfif includeAttribute> 
             <cfset includeAttribute = NOT listFindNoCase(excludeAttributes , variables.Name)>
        </cfif>
        
		<cfif includeAttribute>
				<cfset row = queryAddRow(getAttributes, 1)>
                <cfset getAttributes.DisplayName[row] = variables.Displayname>
                <cfset getAttributes.Type[row] = variables.Type>
                <cfset getAttributes.Value[row] = variables.Value>
                <cfset getAttributes.Name[row] = variables.Name>
		</cfif>
</cfloop>

Open in new window

0
 

Author Closing Comment

by:lonnyo
ID: 38316122
That was the problem.  Your awesome! Thank you so much.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38316135
Welcome :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

873 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