Friday, March 30, 2007

CFUnited is coming up

I wanted to take a break from working on Scorpio, the next major ColdFusion release, to plug CFUnited. Here are the top 5 reasons to attend:
  1. I am speaking. See my weirdly scaled face here. I am giving a talk on how ColdFusion Scorpio will integrate with the latest release of Flex Data Services. It will contain some of the material that I covered at MAX last year, but I think many of those attendees will want to hear it all again now that they have had a chance to try CFMX 7.0.2 and FDS 2.01 together. You have tried it out, right?
  2. CFUnied is the ColdFusion conference. I don't mean to slight the others, I love them too. (In fact I am trying to wrangle my way over to cf.Objective in May because I spoke there last year and had a great time.) But CFUnited is where we (the CF Team) have decided to show up in force. While we love MAX, it isn't the Allaire DevCon any more. CFUnited comes close for me.
  3. Scorpio. Can't really say much about this, but I'll bet that there will be lots of stuff for us Adobe types to talk about. :-)
  4. Its Fun. I don't think I paid for a drink or a meal last year. That is a good thing!
  5. You will learn a lot. The speakers lined up are always top notch and I consider it part of my job description to attend as many sessions as possible. I always learn something new, even if it another crazy way that CF users have taken something we've done and used it in a way we didn't expect at all. Also, did I mention I am speaking?
In any case, anyone who uses ColdFusion should try to attend if they can.

ColdFusion MX 7.0.2 Cumulative Hot Fix 2

In case you miss it on one of the many places that are publishing this information, Adobe has release the ColdFusion MX 7.0.2 Cumulative Hot Fix 2. This wraps up a bunch of fixes that you may (or may not) be interested in. Enjoy!

P.S. Scorpio is coming along nicely and the end is in sight if I squint real hard with the sun at my back. :-)

Friday, March 02, 2007

Apache Axis and Commons HTTPClient

Someone asked me how they could turn on NT Authentication for web service using Apache Axis (the web service used by ColdFusion). By default Axis uses its own HTTP client code, org.apache.axis.transport.http.HTTPSender, to send the XML/SOAP POST requests to a web service. This uses HTTP 1.0 and generally works file.

Axis also supports the Jakarta Commons HTTPClient library, and has since 1.0. To configure Axis to use this instead of its own library you must edit the client-config.wsdd file used by Axis. It gets found on the classpath and generally you don't actually have one and the one built in to axis.jar gets used.
The interesting line is the http transport. To switch Axis to use the HTTPClient jar, you would change this:

<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"></transport>

To this:

<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"></transport>

Once you have this code configured, Axis will use the HTTPClient library for it HTTP needs. Since the HTTPClient library supports NT Authentication, you just set the username/password on the Stub object as you would normally do for (say) Basic Authentication and it will just work. If you are talking to a .NET web service, you are done.

BUT switching the line in the client-config.wsdd file alone doesn't do the trick if you are talking to a ColdFusion web service. Talking to a ColdFusion web service via Apache, you will get an "411 - length required" error back that looks like this:

The Apache JRun connector doesn't allow chunked encoding without a content length (generally true for all general pupose connectors, including mod_python) and the CommonsHTTPSender class in Axis does not provide a content-length. Go figure.
Using the built-in JRun web server you get a a "content not allowed in prolog" error because it appears the JRun web service doesn't understand chunked transfer encoding. Go figure again.
I didn't try it with IIS. My guess it that it might work.
To solution? Turn off the chunked encoding, which you can do by setting a property on the web service object in CFML like this:

ws = CreateObject("webservice", "http://localhost/ws/service.cfc?wsdl");
httpheaders = CreateObject("java", "java.util.Hashtable").init();
httpheaders.put("chunked", "false");
ws._setProperty("HTTP-Request-Headers", httpheaders);
result= ws.myOperation();

The Apache code wants a Hashtable, where it should just look for a Map, so you can't just use a CFML structure for the value of the HTTP-Request-Headers.