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
LVL 2
nmaranoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SidFishesCommented:
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?
0
nmaranoAuthor Commented:
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
0
SidFishesCommented:
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

nmaranoAuthor Commented:
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
0
SidFishesCommented:
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...
0
_agx_Commented:
I think CF is wddx encoding the response.  Try adding returnformat="plain" to your remote cffunction call.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nmaranoAuthor Commented:
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

0
SidFishesCommented:
"I think CF is wddx encoding the response.  Try adding returnformat="plain" to your remote cffunction call. "

good call...

also

returntype="XML" rather than string


Edit: just to clarify - the wddx format converts the < & > to html entities which is useful for ajax, but not so much for xml
0
nmaranoAuthor Commented:
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

0
SidFishesCommented:
oops - at minimum you should split points with _agx_ You may have missed the post I was actually quoting which was the answer...
0
nmaranoAuthor Commented:
Sorry didn't see that!  Sorry AGX- Will split points....I thought I was looking at the same post.
0
_agx_Commented:
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.
0
nmaranoAuthor Commented:
I've asked the moderator to split them.  Thank you both for the help!
0
nmaranoAuthor Commented:
Thanks to you both for the help.  Both of your suggestions cleaned up my code and got it to function properly!

Thanks again
Nick
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.