Avatar of nmarano
nmarano asked on

CF XML Format

Experts-

I have a cfc that I am using as a web service and is getting info from a query and returning the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
    <cfsavecontent variable="CampaignInfo">
      <campaigns>
        <cfoutput query="getCampaignInfo">

            <campaign id="#ct_id#">
            <offer>#ct_offer#</offer>
            <campaignname>#ct_name#</campaignname>
            <location>#ct_location#</location>
            <headline>#ct_headline#</headline>
            <state>#ct_state#</state>
            <content1>#ct_content1#</content1>
            <content2>#ct_content2#</content2>
            <isAllowAppointment>#ct_isAllowAppointment#</isAllowAppointment>
          </campaign>
        </cfoutput>
      </campaigns>

Open in new window


The client currently making the call is receiving the response which looks like this...
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <ns1:landingPageAssetsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservices">
   <landingPageAssetsReturn xsi:type="xsd:string">

      &lt;campaigns&gt;

        



             &lt;campaign id=&quot;1440&quot;&gt;

            &lt;offer&gt;&lt;/offer&gt;

            &lt;campaignname&gt;TestDealer-GutterHelmet (UNLIMITED)&lt;/campaignname&gt;

            &lt;location&gt;&lt;/location&gt;

            &lt;headline&gt;&lt;/headline&gt;

            &lt;state&gt;AL&lt;/state&gt;

            &lt;content1&gt;&lt;/content1&gt;

            &lt;content2&gt;&lt;/content2&gt;

            &lt;isAllowAppointment&gt;0&lt;/isAllowAppointment&gt;

          &lt;/campaign&gt;

        

      &lt;/campaigns&gt;

    </landingPageAssetsReturn>
  </ns1:landingPageAssetsResponse>
 </soapenv:Body>
</soapenv:Envelope>

Open in new window


Does anyone know why all of the opening and closing tags are being shown as the "&lt" "&gt"



I even added xmlformat to each var, but the tags still show with the "&lt" "&gt"

Any help would be appreciated.
-Thanks
Nick
ColdFusion Language

Avatar of undefined
Last Comment
nmarano

8/22/2022 - Mon
SidFishes

well that's totally broken XML...

THis isn't my specialty at all but I believe this happens when you embed pure XML in a SOAP body.

Question is why is that returning a soap response at all. Your cfc should product pure XML. Perhaps they are calling it incorrectly?
ASKER
nmarano

Sid-

I'm wondering the same thing.  The cfc does produce pure XML.  I tested it from an external server and this is what was dumped on screen...

<?xml version="1.0" encoding="UTF-8"?> <campaigns> <campaign id="1440"> <offer/> <campaignname>TestDealer-GutterHelmet (UNLIMITED)</campaignname> <location/> <headline/> <state>AL</state> <content1/> <content2/> <isAllowAppointment>0</isAllowAppointment> </campaign> </campaigns> 

Open in new window


Granted I used a cfm page to call the web service, but I didn't parse anything, I just called the webservice and dumped the var campaignInfo

I'm new to XML and web services....is there a way for me to make a call to the web page and get the XML packet to display on screen without a cfm extension simply as a test?

-Nick
SidFishes

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
nmarano

LOL!   That was easy....



It looks correct to  me, so I think you may be write, it may be the way they are calling it....

Do you mind taking a quick look?

http://admin.keywordconnects.com/webServices/ionCampaignData.cfc?wsdl&method=landingpageassets&cid=1440
SidFishes

hmm - The reponse looks fine in the browser but .... looking at the response in firebug (which is the raw response) I see:

&lt;campaigns&gt;<char code='0a'/>        <char code='0a'/><char code='0a'/>            &lt;campaign id="1440"&gt;<char code='0a'/>            &lt;offer/&gt;<char code='0a'/>            &lt;campaignname&gt;TestDealer-GutterHelmet (UNLIMITED)&lt;/campaignname&gt;<char code='0a'/>            &lt;location/&gt;<char code='0a'/>            &lt;headline/&gt;<char code='0a'/>            &lt;state&gt;AL&lt;/state&gt;<char code='0a'/>  

Open in new window


So something isn't correct here.

Can you post your whole cffunction so we can see what's up...
ASKER CERTIFIED SOLUTION
_agx_

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
nmarano

So I have the XML part look like both of these....

<cfcomponent>
  <cffunction name="landingPageAssets"
    access="remote"
    returntype="string"
    output="no">

    <cfargument name="cid"
    type="numeric"
      required="yes">
 

    <cfset Var campaignInfo = "">
    <cfset Var getCampaignInfo = "">
    <cfquery name="getCampaignInfo" datasource="#application.dsn#">
       select ct.id as ct_id
            ,ct.name as ct_name
            ,ct.location as ct_location
            ,ct.offer as ct_offer
            ,ct.headline as ct_headline
            ,ct.defaultState as ct_state
            ,ct.content1 as ct_content1
            ,ct.content2 as ct_content2
            ,ct.image1 as ct_image1
            ,ct.isAllowAppointment as ct_isAllowAppointment           
            from clients ct
            where ct.id = #arguments.cid#
    </cfquery>
	<?xml version="1.0" encoding="ISO-8859-1"?>
    <cfsavecontent variable="CampaignInfo">
      <campaigns>
        <cfoutput query="getCampaignInfo">
          <campaign id="#ct_id#">
            <offer>#XMLFormat(ct_offer)#</offer>
            <campaignname>#XMLFormat(ct_name)#</campaignname>
            <location>#XMLFormat(ct_location)#</location>
            <headline>#XMLFormat(ct_headline)#</headline>
            <state>#XMLFormat(ct_state)#</state>
            <content1>#XMLFormat(ct_content1)#</content1>
            <content2>#XMLFormat(ct_content2)#</content2>
            <isAllowAppointment>#ct_isAllowAppointment#</isAllowAppointment>
          </campaign>
        </cfoutput>
      </campaigns>
    </cfsavecontent>

    <cfreturn campaignInfo>
  </cffunction>
</cfcomponent>

Open in new window


AND also with the <cfmxl> tag which is the current version on the server

<cfcomponent>
	<!--- Ion will be calling this method/function when they make the 
		call to the web service.
	--->
  	<cffunction name="landingPageAssets"
        access="remote"
        returntype="string"
        output="no">
	<!--- the url strings on the landing pages contain a url var named
		"ctid".  Ion will take this ctid and pass it to the web service
		as the var named cid
	--->
    <cfargument name="cid"
    	type="numeric"
      	required="yes">
 
	<!--- Set an empty local var here to hold the information
			that we are returning
	--->
	<cfset Var campaignInfo = "">
    <!--- Making sure we have a clean query result --->
    <cfset Var getCampaignInfo = "">
    <!--- Get the campaign information based on the cid that was passed
			from ion
	--->
    <cfquery name="getCampaignInfo" datasource="#application.dsn#">
       select ct.id as ct_id
            ,ct.name as ct_name
            ,ct.location as ct_location
            ,ct.offer as ct_offer
            ,ct.headline as ct_headline
            ,ct.defaultState as ct_state
            ,ct.content1 as ct_content1
            ,ct.content2 as ct_content2
            ,ct.image1 as ct_image1
            ,ct.isAllowAppointment as ct_isAllowAppointment           
            from clients ct
            where ct.id = #arguments.cid#
    </cfquery>
    <!--- This tag allows for well formed XML --->
	<cfxml variable="CampaignInfo">
    
      <campaigns>
        <cfoutput query="getCampaignInfo">

            <campaign id="#ct_id#">
            <offer>#ct_offer#</offer>
            <campaignname>#ct_name#</campaignname>
            <location>#ct_location#</location>
            <headline>#ct_headline#</headline>
            <state>#ct_state#</state>
            <content1>#ct_content1#</content1>
            <content2>#ct_content2#</content2>
            <isAllowAppointment>#ct_isAllowAppointment#</isAllowAppointment>
          </campaign>
        </cfoutput>
      </campaigns>
   </cfxml>

    <cfreturn campaignInfo>
  </cffunction>
</cfcomponent>

Open in new window

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
nmarano

Thank you sir!  I believe that did it.  Now when I look at the source, I'm getting this...

<?xml version="1.0" encoding="UTF-8"?>
<campaigns>
        
          <campaign id="1440">
            <offer/>
            <campaignname>TestDealer-GutterHelmet (UNLIMITED)</campaignname>
            <location/>
            <headline/>
            <state>AL</state>
            <content1/>
            
            <isAllowAppointment>0</isAllowAppointment>
            <googlecityname>Brooklyn</googlecityname>
            <googlestate>CT</googlestate>
            <googlecityabb>Brooklyn</googlecityabb>
          </campaign>
        
      </campaigns>

Open in new window

SidFishes

oops - at minimum you should split points with _agx_ You may have missed the post I was actually quoting which was the answer...
ASKER
nmarano

Sorry didn't see that!  Sorry AGX- Will split points....I thought I was looking at the same post.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
_agx_

No problem. I figured that's what happened. No worries really, I just chimed in w/a brief comment between meetings :) ,Sid did most of the work.
ASKER
nmarano

I've asked the moderator to split them.  Thank you both for the help!
ASKER
nmarano

Thanks to you both for the help.  Both of your suggestions cleaned up my code and got it to function properly!

Thanks again
Nick
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.