So here's the low-down on SnipEx.

I've been playing around with this for a while this evening and there is a difference in behavior between CFCs on OpenBD and Adobe CF in this case.

Basically the main SnipEx CFC sets url.method on the fly based on what parameters are or aren't in the URL, and with url.method defined on the fly, that calls the corresponding method in the CFC. This works on Adobe CF.

On OpenBD when no parameters are defined in the URL explicitly a 403 error is thrown on Tomcat, and when a method isn't defined in the URL (e.g. SnipEx.cfc?libid=1), OpenBD throws the error "the request must contain a METHOD parameter."

I'll throw that in the bug tracker so we can investigate compatibility on this issue.

All is not lost however!

To give a bit of background (and you may already know this), SnipEx is designed to be used in conjunction with CFEclipse to provide centralized, remote access to snippets from within Eclipse. The application as written runs from two CFCs.

But given the apparent compatibility issue with the CFCs, I added a CFML file into the mix that seems to have done the trick. I did also modify the CFCs a bit just to do some cleanup--added returntype to the CFC methods and some other very minor changes.

The basic steps are:
1. create a database--I modified the database script a bit and used the H2 embedded database in MySQL mode

2. insert a record into the lib table in the database for your first snipex library

3. configure some settings in Application.cfc, specifically application.rootID (which needs to match the ID of the record you created in #2 above) and application.dsn (which needs to be your datasource name that you created in OpenBD)

4. add the CFML file in the mix to handle requests and call the appropriate CFC method

Here's the contents of the CFML file--I named this snipex.cfm:
<cfif structKeyExists(URL, "libid")>
   <cfset URL.method = "getLibrary" />
<cfelseif structKeyExists(URL, "snipid")>
   <cfset URL.method = "getSnippet" />
<cfelseif NOT structKeyExists(URL, "method")>
   <cfset URL.method = "getSnipEx" />
</cfif>

<cfset snipex = createObject("component", "SnipEx") />

<cfswitch expression="#url.method#">
   <cfcase value="getLibrary">
       <cfset snipex.getLibrary(url.libid) />
   </cfcase>
<cfcase value="getSnippet">
       <cfset snipex.getSnippet(url.snipid) />
   </cfcase>
<cfcase value="getSnipEx">
       <cfset snipex.getSnipEx() />
   </cfcase>
</cfswitch>

Looking at this again you should really create a single instance of SnipEx CFC in the application scope and just refer to that, but hey, I was just trying to get things working. ;-)

Now at this point you can hit a couple of URLs in your browser and get XML back; this is assuming a context path of snipex and a lib id of 1:
http://localhost:8080/snipex/snipex.cfm (this will call getSnipEx)
http://localhost:8080/snipex/snipex.cfm?libid=1 (this will call getLibrary)

So if you're seeing XML in the browser, that means it's working.

Next you go into CFEclipse and configure this as a snipex server, using http://localhost:8080/snipex/snipex.cfm as the URL instead of hitting the CFC directly.

This worked for me--let me know if any of this needs to be clarified. I can zip up the working OpenBD code if people are interested.

--
Matt Woodward
[EMAIL PROTECTED]
http://www.mattwoodward.com/blog

Please do not send me proprietary file formats such as Word, PowerPoint, etc. 
as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to