Trying to figure something out. Hope someone here...
# fw1
d
Trying to figure something out. Hope someone here may have an idea. I am working to port over a legacy app into FW/1. Where I am struggling is a couple hard requirements. The first is that I have to have the app still work with old urls. Second, is that I still have to support webservice WSDL calls. The part I am struggling with is supporting the legacy WSDL urls. They will eventually be converted to rest calls but that is down the road. Normally I would just put in some url rewrites and be done with it. However, I can't (not my decision). URL rewrites are completely off the table as a solution. I have been able to get it working in parts using onMissingTemplate and a redirect. That works, but also doesn't. Redirects on a webservice call causes some odd errors on the caller. So I have to figure it out without using a redirect. Ideally, if I can just call a controller from onMissingTemplate that would probably work. However, I can't seem to get that to work either. So, any ideas? I feel like I am missing something simple that would handle this but ???
b
Can you use application routes to take an old URL and have it invoke the desired controller & item? You should be able to map multiple URLs to the same handler, so you can have both the old URL and your preferred URL operating at the same time, possibly. Assuming you're collecting the same data through the URL, anyway.
This should work without any redirects unless you want to detect the old URL and force a redirect to the new URL.
d
Yea... getting it to invoke a controller would be ideal. However, I can't seem to get that to work properly from inside onMissingTemplate. From what I can tell, inside this function all the "fw/1" parts are not available .
a
Do your WSDL calls look something like
/foo/bar.cfc?wsdl
I'm not quite sure why you need to have FW1 know about the legacy WSDL urls? If they work currently why does FW1 need to know about them? If the code in the legacy CFC needs to know about DI/1 then that is in the application scope so not ideal but you can reference it to get beans etc.
Or are you replacing the legacy CFC and need FW/1 to intercept the call and route to ca controller?
d
It would be the latter. All the legacy code is being put into FW/1. Ultimately we are getting rid of the WSDL urls and converting everything to rest but we need to support the WSDL in the mean time.
a
I figured it was the latter after posting because you mentioned
onMissingTemplate
. Yeah that's a tricky one - not sure how to handle that at a an app level.
b
I might be missing something, but if the URL route is defined and pointed to a controller that exists, why is onMissingTemplate in the mix?
a
Because if you call a script that doesn't exist then the CFML engine will say "no idea what to do with that" so it then calls the onMissingTemplate
It's hitting say
/foo/bar.cfc
which doesn't exist.
Only think I can think of is to create a stub
foo/bar.cfc
and the within that delegate to your FW1 model (using the beanfactory)
At least I assume tat's the issue here (sorry for jumping in!)
b
I guess i'm used to an Apache rewrite that pushes any request to a non-existent file through to the CF application for handling
so in that case, the url
/foo/bar.cfc
would still get routed through FW1
d
yea.. that is a possibility. That was kind of my last resort. But like I said prior, If I could figure out how to call a controller from onMissingTemplate all would be good
Mark, Like I said at the beginning.. I can;t use URL rewrite at all. Not my call, restriction being force on me.
a
I think
onMissingTemplate
is called really early as it's the CF engine calling that - so would be before FW/1 is in the mix.
d
It is
a
Wonder if
onCFCRequest
would help...
d
I can kinda "force" fw/1 to be involved in OnMissing by calling onRequestStart
a
You may be able to override the action as think that's stored in the request scope. So that when FW/1 runs it uses the 'forced' action.
Just throwing out ideas here - I don't know the answer - sorry!
d
Thanks for the ideas/input. I have been able to run controller() in onMissingTemplate. However nothing that should be happening happens. Dumping the request scope I do see the controller has been queued in the trace. But that is where the trace ends. Trying to run different combinations of the application "on" functions doesn't seem to work either.
After much trial and error I think I figured it out. Here is what I did that worked... in OnMissingTemplate I set 3 vars: • url.action to the section and item I need. • request.action = url.action; • request._fw1.cgiscriptname = "/index.cfm" I then called • onRequestStart("/index.cfm"); • onRequest("/index.cfm");
These changes allowed me to funnel the request to the appropriate controller.
🙌 1