CFMX 6.1 - getting "Method not allowed" error

6 views
Skip to first unread message

Andy Matthews

unread,
Jun 15, 2006, 3:54:48 PM6/15/06
to JSMX
I recently found JSMX and decided to give it a try. MUCH easier to
configure than CFAJAX and looks to be easier to use as well. Great job
on working up this code, and thank you for making it public!

I'm having an issue though running the code at the bottom. Using
LiveHTTP headers I get the following:

HTTP/1.x 405 Method Not Allowed
Date: Thu, 15 Jun 2006 19:46:58 GMT
Server: Apache
Allow: GET, HEAD, OPTIONS, TRACE
Keep-Alive: timeout=15, max=10000
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

Here's the test page:
http://www.commadelimited.com/travian/test.html

I'm able to use CFCs and in fact, I'm using them exclusively for this
site. I'm not however calling any of them remotely, which I suppose
could be the issue. This will be the first time I've called a CFC
remotely.

Do you have any ideas as to what could be occurring?

======== begin code block ============
<html>
<head>
<title> new document </title>
<script src="includes/js.js"></script>

<style type="text/css">
<!--
#yourDiv { display: none; }
#myDiv { display: block; }

-->
</style>

<script>
function findzip_request(){
param = 'zip='+document.getElementById('zipcode').value;
http( 'POST' , 'includes/q.cfc?method=findZipCode' , findzip_response
, param );
}

function findzip_response(obj){
document.getElementById('city').innerHTML = obj.city;
document.getElementById('state').innerHTML = obj.state;
document.getElementById('yourDiv').style.display = 'block';
document.getElementById('myDiv').style.display = 'none';
}
</script>

</head>
<body>


<fieldset>
<legend>Enter a U.S. ZipCode and submit.</legend>
<p> <input id="zipcode" type="text">
<input type="button" value="Find Zip"
onclick="findzip_request();"></p>
<p> <label>City:</label> <span id="city"></span></p>
<p> <label>State:</label> <span id="state"></span></p>
</fieldset>
<br><br>

<div id="myDiv">Register now.</div>

<div id="yourDiv">You're logged in, that's great!</div>

</body>
</html>


Here's the function, pretty much unchanged from your example code:
<cffunction name="findZipCode" access="remote" returntype="void">
<cfargument name="zip" type="string" required="Yes"
default="00000">

<cfset result = structNew()>
<cfset result.city = "N/A">
<cfset result.state = "N/A">

<cfset zipURL =
"http://www.webservicex.net//uszip.asmx/GetInfoByZIP">
<cfhttp method="GET" url="#zipURL#?USZip=#arguments.zip#"/>
<cftry>
<cfset addyObj = xmlParse(cfhttp.filecontent)>
<cfset result.city =
trim(addyObj.newDataset.table.city.xmlText)>
<cfset result.state =
trim(addyObj.newDataset.table.state.xmlText)>

<cfcatch><!--- do nothing ---></cfcatch>

</cftry>

<cfwddx action="CFML2JS" input="#result#" toplevelvariable="r">
</cffunction>
======== end code block ============

Andy Matthews

unread,
Jun 15, 2006, 4:14:50 PM6/15/06
to JSMX
One thing I forgot to mention...this code works perfectly on my local
dev machine.

2

unread,
Jun 15, 2006, 4:19:27 PM6/15/06
to JS...@googlegroups.com
The server is returning a 405 error. This is because the ALLOW header is
stating: Allow: GET, HEAD, OPTIONS, TRACE

And you are doing a POST. You can try to run this as a GET and place the
"params" variable in the queryString instead. Or modify the Header. XHR
makes it pretty easy to modify headers but the JSMX abstraction layer (ie..
http() ) may make that a bit more difficult to get to. You can open up
engine.js and modify it if you feel confident in doing so.

I'll look into a way to expose the headers in my next version release.

HTH,
-Todd

Andy Matthews

unread,
Jun 15, 2006, 5:11:05 PM6/15/06
to JSMX
I've gotten my code to work using the Classic example, but I'd really
like to figure out how to get the CFC version working so that I can
combine all of my code into one library.

I tried changing the CFC based function from this:


param = 'zip='+document.getElementById('zipcode').value;

http( 'POST' , 'includes/jsmx.cfc?method=findZipCode' ,
findzip_response , param );

to this:


param = 'zip='+document.getElementById('zipcode').value;

http( 'GET' , 'includes/jsmx.cfc?method=findZipCode&' + param,
findzip_response , param );

But I'm still getting the same error. I'm sorry about this but I'm not
all that great with javascript.

Andy Matthews

unread,
Jun 15, 2006, 9:55:26 PM6/15/06
to JSMX
Is it possible that something in the CFADMIN is set to disallow this
sort of connection. On your suggestion to another poster I tried
connecting directly to the CFC via an http request and it tried to
DOWNLOAD the CFC instead of parse it out. Check it:
http://www.andyandjaime.com/jsmx/remote.cfc

That's a different CFC but you can see that it actually let's you
download the CFC completely intact. That's got to be the reason this is
happening...I just don't know why.

2

unread,
Jun 15, 2006, 10:44:22 PM6/15/06
to JS...@googlegroups.com
This sounds more like an http server issue (ie: IIS, Apache, etc..) rather
then a CFADMIN or even an Ajax/JSMX issue.

I feel silly for asking this but, you are running MX and not CF5 aren't you?

Based on the response I got when I called your page, it seems like you might
be running a "pre-MX" version of CF that doesn't support .cfc.

I called the CFC directly via the URL you provided and checked the mime type
that was returned (which was "text/plain") which would indicated the http
server doesn't understand the file extension so it is returning it as plain
text.

Assuming you're running CF5 or earlier, that would make sense. If you are
running MX then perhaps your install was corrupted. Are there CFC's that you
can call successfully on that server?

Check either your ISAPI setting in IIS or the httpd file in Apache and make
sure the .cfc file extension is included. If not, just add it in using the
same settings as .cfm.

Hopefully that helps,
-Todd


-----Original Message-----
From: JS...@googlegroups.com [mailto:JS...@googlegroups.com] On Behalf Of Andy
Matthews
Sent: Thursday, June 15, 2006 6:55 PM
To: JSMX

Todd

unread,
Jun 15, 2006, 10:49:32 PM6/15/06
to JSMX
this problem is based on the underlying issue of not being able to
access CFC's. Once you get that working, this should be fine. (though
if you are including param in the querystring you do not need to pass
it as a 4th argument.).

Andy Matthews

unread,
Jun 16, 2006, 10:53:13 AM6/16/06
to JSMX
Nope...I'm using CFMX 6.1 (CF fo life babee).

It appears that there's some sort of proxy stuff going on with our
server cluster. Our system is passing requests for CFM pages through to
an alternate server, but not for CFC pages. Since I'm the only one in
our company using CFCs this apparently got overlooked. They're making
the update now and hopefully (crosses ffingers) it'll be fixed when the
servers get restarted.

Thanks for all of your help.

Reply all
Reply to author
Forward
0 new messages