Webservices - why in a subdirectory?

ColdFusion Add comments

I’ve just been playing with webservices for the first time and come across a few ‘gotchas’ which i’m a little curious about. Firstly, if i place a CFC in my webroot locally I can view the XML descriptor by accessing it as http://localhost/mycfc.cfc?wsdl but if i put the same CFC up to my hosted account i get an Axis error returned (if the CFC is in the site root). I did some digging and found someone who’d had a similar problem and the problem went away if you move the CFC to a sub directory beneath the site root. Sure enough, if i move mycfc.cfc to a folder ‘cfcs’ off my site root and amend the url I can view the descriptor and call methods on it remotely.

Now this could be a ‘common’ occurance but i couldn’t find any technotes on the subject and the documentation doesn’t indicate this. Any thoughts?

2 Responses to “Webservices - why in a subdirectory?”

  1. Niklas Richardson Says:

    Hi John,

    Yeah, there are a couple of gotchas.

    You might be having this problem with CFCs on your hosting company as they may have the "/" mapped to somewhere else.

    We’ve found when using flash remoting you need to put your CFCs in a sub directory with the same name as the CF mapping to the directory that contains your CFCs (if that makes sense).

    So, for example. If you have your CFCs in a directory who’s CF mapping is "/cfc" you need to have a web server virtual directory called "/cfc" that points to the same physical directory that has your CFCs in.

    Regards

    Niklas

  2. Sean Corfield Says:

    Niklas is pretty much spot on there. Shared hosts often have / mapped and that will confuse the web service mechanism. Once you move it to a subdirectory, the path no longer behaves like a mapped path (so it works).

    I don’t remember the exact details but web services and direct CFC calls use different path resolution methods to locate the CFC. There’s been various discussions on CFCDev and cf-talk in the past I think.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in