Link to home
Start Free TrialLog in
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
Avatar of SidFishes
SidFishes
Flag of Canada image

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?
Avatar of nmarano
nmarano

ASKER

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
Avatar of nmarano

ASKER

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
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
Avatar of _agx_
_agx_
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
Avatar of nmarano

ASKER

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

SOLUTION
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
Avatar of nmarano

ASKER

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

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

ASKER

Sorry didn't see that!  Sorry AGX- Will split points....I thought I was looking at the same post.
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.
Avatar of nmarano

ASKER

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

ASKER

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

Thanks again
Nick