?
Solved

ColdFusion WDDX/Web Service/XML

Posted on 2003-03-16
14
Medium Priority
?
451 Views
Last Modified: 2013-12-20
A small company has asked two provider (myself and another) to work together on providing dynamic content to the web. I am using CFMX and MSSQL for a CRM database. Our application is working fine, but the other provider is Devlopmentally challenged. We want to display the contents of an events calendar on their web page (BTW, the web site is hosted on a different server). I attempted the web service thing with complex data types (querybean) and that was a little much for them. I am currently trying to do it through WDDX in which I am receiving positive results, but I can't seem to get the consuming page to read the CFMLtoJS output without the CFHTTP tag. My question is what is the best way to make the events data available to them without running a batch process to update XML, or a text file, or WDDX on a daily basis. Let me outline:

1. CFMLtoJS is outputing fine.
2. I either want them to:
     a. Include a CFM page with the CFMLtoJS at the top of the referring page
     b. Include a CFM page with XML output at the top of the referring page (or read the XML from a CFM page)
     c. Use a robot to get the WDDX packet or XML data
     d. Use a web service to return the query
     e. Get them to purchase and learn CF

Any help will be greatly appreciated...I am running on empty.
     d.
0
Comment
Question by:jg4smile
[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
  • 7
  • 5
  • 2
14 Comments
 
LVL 3

Expert Comment

by:cdillon
ID: 8151961
I wouldn't use cfml2js if they have their own coldfusion server:

<cfquery datasource="probono" name="events_query">
  events query here1
</cfquery>

<cfwddx action="cfml2wddx" input=#events_query# output="todisplay">

<cfoutput>#todisplay#</cfoutput>

Then on the client side, they can use the results just like a query. Use cfhttp to get this page wddx results into a variable then:

<cfwddx action = 'wddx2cfml' input = #wddxText# output = 'qnew'>

The recordset data is:...<P>
<cfoutput query = qnew>
  #qnew.field#<br>
</cfoutput><P>

Alternatively, they can store your content in their own database so it doesn't have to get the content from your server each time.
0
 
LVL 1

Expert Comment

by:Wasistdas
ID: 8156386
Use javascript to give them your data:

give them a code they can place within their site:

<script language="javascript" src="http://your_site/giving_data.cfm">
</script>

Then in giving_data.cfm place whatever data you want them to display:

------ start givin_data.cfm (example) -----
document.write('<cfquery name="itsonline" datasource="#dsn#" username="#dsn_login#" password="#dsn_pw#"> select player.id from player </cfquery>');
document.write('<cfset needLastLoad = createODBCDateTime(dateAdd("n", -10, now()))>');
document.write('<cfquery datasource="#dsn#" name="pOnline" username="#dsn_login#" password="#dsn_pw#"> select count(*) as cnt from player where lastLoad >= #needLastLoad# </cfquery>');
document.write('<cfoutput>#pOnline.cnt#/#itsonline.recordcount# players<p>#gameName#<br></cfoutput></p>');
------ end givin_data.cfm -----

Just remember - one process per document.write.
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8210459
Okay, both solutions above worked except the other company does not have CF. Here's is the where things are. I generated XML from a CFML page (see snippit below):

------ gen_xml.cfm -----

<cfquery name="qry" datasource="#application.dsn#">
select id, dt_event, event, sdesc from schedule;
</cfquery>

<cfxml variable="tmp">
   <schedule>
      <cfoutput query="qry">
         <event id="#id#" dt_event="#dt_event#">
            <ename>#event#</ename>
            <sdesc>#sdesc#</sdesc>
         </event>
      </cfquery>
   </schedule>
</cfxml>

<cfcontent
   type="text/plain"
   reset="yes"><cfoutput>#tostring(tmp)#</cfoutput>

------ gen_xml.cfm -----

From my development environment it shows this page as well-formatted XML (which is what I want), but from the web server it asks me if I want to download (Open/Save/Cancel) the page. Is the XML available behind this message or is there something else I'm missing? Thanks for your assistance.
0
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
LVL 3

Expert Comment

by:cdillon
ID: 8210717
Choose save - then you can rename the file output.txt - you should be able to edit and see the xml.  On the original problem, I'm not sure I understand your desired goal.  Do you want them to be able to download the events in WDDX format?   You can name the file that is returned something other than gen_xml.cfm by including the line.

<cfheader name="Content-disposition" value="filename=weekly_events.xml">

weekly_events.xml is just an example name, you can rename it anything.
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8210770
Okay, here is the ultimate goal....

They use the the url to this XML or WDDX page as the source for their own process. I want them to simply reference this page as a datasource. For example, if they are using ASP or Java to parse XML, I want them to reference "http://vnd/schedule.cfm" as the source for the XML. schedule.cfm would dynamically generate the XML at each request (like a web service).
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8210819
Okay, both solutions above worked except the other company does not have CF. Here's is the where things are. I generated XML from a CFML page (see snippit below):

------ gen_xml.cfm -----

<cfquery name="qry" datasource="#application.dsn#">
select id, dt_event, event, sdesc from schedule;
</cfquery>

<cfxml variable="tmp">
   <schedule>
      <cfoutput query="qry">
         <event id="#id#" dt_event="#dt_event#">
            <ename>#event#</ename>
            <sdesc>#sdesc#</sdesc>
         </event>
      </cfquery>
   </schedule>
</cfxml>

<cfcontent
   type="text/plain"
   reset="yes"><cfoutput>#tostring(tmp)#</cfoutput>

------ gen_xml.cfm -----

From my development environment it shows this page as well-formatted XML (which is what I want), but from the web server it asks me if I want to download (Open/Save/Cancel) the page. Is the XML available behind this message or is there something else I'm missing? Thanks for your assistance.
0
 
LVL 3

Expert Comment

by:cdillon
ID: 8211640
The query/code you gave should work if that is how you want your xml formatted.  They can get this xml from your server if their processes support getting documents from the web.  They will need to know that even though your file ends in .cfm it produces xml output.
0
 
LVL 1

Expert Comment

by:Wasistdas
ID: 8212348
In my variant the company you wish to give your data to doesnt need to own CF. You can use my variant in any pages in any places. The data is parsed on your server. Just give it a test and you see it works perfect.

I used this tech to give my data to a site built on php. All works perfect.
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8216714
Okay, last response before I award the points. Everything appears to be in order, except when I use the toString() function on the generated XML object, it returns the value "null" to the screen. I know it is not the code, because when I <cfdump> the same XML variables all of the info is there. Any ideas? Are there any alternatives other than the toString function? Wasistdas, I am not sure what you mean by "my variant".
0
 
LVL 3

Accepted Solution

by:
cdillon earned 800 total points
ID: 8217273
If you want to output the xml, why are you converting it to a structure in memory.  Try:

<cfquery name="qry" datasource="#application.dsn#">
select id, dt_event, event, sdesc from schedule;
</cfquery>

  <schedule>
     <cfoutput query="qry">
        <event id="#id#" dt_event="#dt_event#">
           <ename>#event#</ename>
           <sdesc>#sdesc#</sdesc>
        </event>
     </cfquery>
  </schedule>
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8224966
If I don't do it in memory, how do I supress the open/save/cancel dialog?
0
 
LVL 3

Expert Comment

by:cdillon
ID: 8225072
Leave out this line:

<cfcontent type="text/plain" reset="yes">

It's what's causing the save dialog. (see code from last comment)

Also, if they are not using a browser they won't get the dialog.
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8225104
First of all CD, I am going to award you the points. Here is the solution although only implemented in the test environment:

<CFCONTENT TYPE="text/xml">
<?xml version="1.0" encoding="utf-8"?>
<schedule>
     <cfloop index="i" from="1" to="10" step="1">
     <cfoutput>
     <event id="#i#">
          <ename>TEST EVENT #i#</ename>
          <sdesc>#i# - This is a test</sdesc>
     </event>
     </cfoutput>
     </cfloop>
</schedule>

I didn't think you could output the data in this manner although I should have thought about CFCONTENT a while back. Also, I didn't think there was a type "text/xml". I actually went back to sending the WDDX/JavaScript to the other company, but they were completely lost. Thanks for all the help fellas. Hopefully I can provide some value for you in the future (...I haven't answered a question in over a month).
0
 
LVL 1

Author Comment

by:jg4smile
ID: 8225118
I think life with CF is only going to get better...unless, of course, they sell out to MS!!!
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Suggested Courses

770 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