Wednesday, November 22, 2006

Rick Strahl Saves the Day

Stonefield Query uses an online activation mechanism so a customer can activate their software without having to contact us for an activation code. When they purchase the software, we assign them a serial number and update a database on our Web site. They install and run Stonefield Query, type in the serial number, and click the Online button. This calls a West Wind Web Connection application on our Web site that returns an activation code. The code on the client site is similar to this:

loHTTP = newobject('wwIPStuff', 'wwIPStuff.vcx')
loHTTP.Connect('www.SomeURL.com')
loHTTP.AddPostKey('SomeKey', 'ValueForKey')
lcPage = 'wc.dll?SomeProcess'
lcHTML = ''
lnLen = 0
try
lnResult = loHTTP.HTTPGetEx(lcPage, @lcHTML, @lnLen)
catch to loException
lnResult = -1
endtry

This works great. However, I got a bug report from one of our support staff the other day. They updated to Internet Explorer 7 and suddenly online activation stopped working. The error message displayed was "invalid handle."

I dreaded having to track this down. First, I had to install IE 7, which I've been putting off doing for a variety of reasons. Second, I'd have to dig into stuff that I'm not really familiar with--the wwIPStuff code and possibly a DLL--to figure out why this is failing. (And why would installing an updated version of an application, albeit one closely tied into Windows, change the behavior of a system DLL anyway?)

However, I remember reading a message on the West Wind Message Board (a great resource even if you don't use any West Wind tools) from a week or so ago stating that the HTTP code in wwIPStuff was deprecated and that wwHTTP should be used instead. I hadn't any reason to revisit any of my code using wwIPStuff because it just worked. So, after installing IE 7, I changed one line of code:

loHTTP = newobject('wwHTTP', 'wwHTTP.prg')

I crossed my fingers and tried the online activation. Problem solved! Since my copy of West Wind Client Tools is a couple of years old (yeah, I know I should update it), clearly pre-dating IE 7, I'm not sure why this worked better than wwIPStuff. In researching the problem later, I found an entry in Rick Strahl's blog that described the problem and the fact that he doesn't know why wwIPStuff fails either. Although I read his blog regularly, clearly I'd missed the significance of this one. Thanks again, Rick, for a great product!

No comments: