ColdFusion Muse

Refreshing a webservice in the Cache

Mark Kruger July 13, 2005 11:29 AM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (7)

Web services are great - but they are not a magic bullet. You have to become familiar will all their little quirks to use them effectively. This is a nice tip I picked up on the email list for BACFUG (I love the retro logo). Sometimes you might have a CFC that you are calling as a webservice like this:

<cfscript>
// service wsdl file
sdl   =   'http:/' & '/mydomain.com/WS/myservice.cfc?wsdl';
// create object
sv = CreateObject('webservice', sdl);
</cfscript>
If you make a change to a method in the CFC (add or change an argument - or a type), and you refresh your page that uses the web service, you may not see the change. That is because the CF Server creates a "stub" (a proxy class) from your WSDL and puts it in the cache. It does not automatically know that the file has changed. You can refresh the cache from the CF administrator, but you may not always have access to it (if you are on a shared server). In fact, the CF Admin method doesn't always work for some reason. Not to worry, Tarik Ahmed (Cflex.net) offers this programmatic solution.
<cfscript>
// service wsdl file
sdl   =   'http:/' & '/mydomain.com/WS/myservice.cfc?wsdl';
// create object
factory = CreateObject('JAVA', "coldfusion.server.ServiceFactory");
// reference to the XmlRpcService
RpcService = factory.XmlRpcService;
// refresh the object in question
RpcService.refreshWebService(sdl);
</cfscript>

  • Share:

Finding all those sneaky log files in Coldfusion

At some point you will have to troubleshoot server problems. Trust me - it will happen. It's no good sticking your head in the sand or your fingers in your ears (or both - tricky, but doable). Your first question will likely be, "Where do I find out information about what is happening on the server." Fortunately there are a great many log files in Coldfusion. Unfortunately they are not easy to find, and they contain different formats of information. There are 3 "groups" of file based logs on a Coldfusion MX installation. These groups are mostly the same for CFMX 7 as they are for CFMX 6 and CFMX 6.1 (a few exceptions). Here's a rundown:

Read More
  • Share:

Using onSessionEnd in Coldfusion 7's new framework

Mark Kruger June 21, 2005 10:38 AM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (9)

The new Application.cfc file (as of Coldfusion MX 7) is a great "step up" for the framework. In case you are not familar with it, here's a rundown. You replace the venerable old "application.cfm" file in the root of your application with an "application.cfc" file. It works in a similar way, but there are some extra features and some gotchas. Basically there are 8 function calls that are made by 8 different events that are a part of any application. To put it another way, when certain things happen within the application it fires 8 possible events - which in turn call these functions.

Read More
  • Share:

Declining or Advancing... What is Coldfusion's New Direction?

Mark Kruger June 7, 2005 12:25 PM Coldfusion MX 7 Comments (6)

There's lots of hand wringing over what the Adobe merger means to Coldfusion. That's very important to me as well. In a recent spate of messages on the CF Guru list Robi Sen asked the question "Is CF growing or Declining". A number of excellent opinions where offered. Here's a synopsis.

Read More
  • Share:

Using a DSN connection for Connectionless Access

Macromedia added "connectionless" DSN's in CF 5, then took them away again in CFMX. This much lamented feature was useful in certain instances. One of my favorites was for data export. For one of our e-commerce sites suppliers wanted a daily Access file for orders. We created an export process that copied an Access template to a new location (an Access db with the tables needed). Then we created an ODBC connection to it using the "connectionstring" attribute of CFQUERY and ran an insert routine to copy in the orders. The file was then zipped and automatically emailed to the supplier for drop shipment. In the words of Jimmy Neutron's Dad, "Now you gotta admit that's pretty neat!".

In CFMX however the connectionstring attribute is gone. This is because the system no longer interacts directly through ODBC. Instead it uses JDBC as the data access layer. That's a very good thing. We have had great results with speed and reliability through JDBC. It does put a crimp in our data export plan however. Fortunately there's a work-around. It's not perfect, but it works pretty well.

Read More
  • Share:

Cool query function tip using array syntax.

I often pull in a full data set then use query of a query to pull subsets of data from it. The purpose is to minimize the number of hits to the database server (which is usually the cheif bottleneck of any application). This works pretty well, but today I stumbled on a tip that can really save some effort and reduce the sheer number of lines of code. It has to do with using aggregate functions to derive other values from the data. For example, if I have a large query that is being output in a row and I want totals at the bottom I usually run a query like this:

Read More
  • Share:

Memory usage on unevenly populated arrays

It sounds like a dull topic. Right up there with "planning for retirement for 20 year olds". However, it certainly is important to understand some of the nuances of arrays and structures because how you use them (and your choices on which one to use can greatly affect the future scalablility of your application.

I saw an excellent discussion recently on an email list. I owe this information on arrays to Pete Freitag and Joe Rinehart. The question posed was, is the "length" of the array strictly tied to the number of members in the array. The reason this is important is because arrays are widely used for reasons of speed. Since an array is a list of references (points) it usually ranks as the fastest way to "loop" through data. I say "usually" to cover my butt. I actually don't know of any faster way in any language - although I'm sure the excellent and knowledgable readers of this blog will happily point some out to me (ha). Anyway, consider this code...

Read More
  • Share:

Report Builder Limitations and CFR files

Mark Kruger May 16, 2005 2:44 PM Coldfusion MX 7, Using Coldfusion Tags Comments (0)

We are all aware that the report builder application is a template generation tool. It's quite useful with a number of nifty features. One of the cool things about it is that you can define a report template using dummy data that can be replaced at run time. This allows you to run and test the display attributes and charts of your report using something simple like CFQUERYNEW( ) which you then replace with the actual query by passing it into the CFREPORT tag.

What I was hoping for however, was a template that produced a file format that we could unpack and examine. Our goal would not be to become report writers for our clients (isn't that really a content editors job?). Our goal is to produce tools where they can mine and access the data themselves. I would love to be able to allow a web based user to generate their own reports from a wizard. Indeed we have a system very much like this for Ms SQL that makes use of the various stored procs for data type introspection and allows a user to build 1 or more queries to use in a report.

The biggest flaw in our system is the rather limited template system we have. I was hoping to be able to replace "front-end" template with an auto-generated CFR file. However, Macromedia in a disappointing move, has chosen to encrypt the CFR files. effectively making them useless except as a limited time-saver for developers faced with handling report content. I suppose a DBA or Access programmer could pretty easily get up to speed on the report builder. But as far as I can see there is no way to make use of this file format programmatically.

  • Share: