Classic ASP and Amazon MWS

Okay, I know I am writing about stuff almost no one cares about. Classic ASP is the Dodo of web programming. Who in their right mind would be writing Classic ASP transactions to Amazon MWS? Isn’t Classic ASP dead! The only saving grace from Amazon not supporting Classic ASP is that Amazon’s support of PHP or C# is  not exactly brilliant. So for the few of you who might be interested, submitting MWS transactions using Classic ASP can be done. Most of the ASP code is already available in the forums. The only trick is the  request and feed signatures.

The key to the request signature problem was to implement Daniel O’Malley’s contribution in the post, I have authentication code for Classic ASP — anyone need it?. The trick was how to create a base64 encoded SHA256 signature that Amazon requires for the request. Several people tried to write native ASP functions for SHA256, MD5, and Base64 encoding but they could not match the results of the Amazon Scratchpad.  Daniel’s solution was to call JavaScript functions from ASP. That was brilliantly simple! He wrote a simple WSC wrapper for the JavaScript code available at http://pajhome.org.uk/crypt/md5/ and published it as sha256.wsc. That was cool! The Base64 encoded SHA256 signatures it generates matches the Amazon Scratchpad. I got it to work on the ListOrders and GetOrder transactions but I needed more. I needed to submit a “_POST_ORDER_FULFILLMENT_DATA_” feed and Amazon required a Base64 encoded MD5 signature for the feed data. This is an important transaction if you want to get paid. If you do not have a lot of Amazon orders your marketing person could update this manually. If you prefer the marketing person to focus on generating more sales, you should probably consider doing this task automatically. In our case we had a system that kept track of tracking numbers for each order.  So I followed Daniel’s example and merged the MD5 code from the same web site into Daniel’s code. My code is called sha256md5.wsc file. My testing confirmed that it generated both sha256 and md5 signatures that matched the Amazon Scratchpad. After a week of posting fulfillment data I have to conclude it is working. Your mileage may vary! Guess what? Our sales are up! I guess the plan of letting marketing folks focus on marketing is working! I love it when a plan comes together!

Since several people asked for it. Here is the wsc file, sha256md5.txt. I hope it helps.

Why do I get 80072EE2 errors?

It took me awhile to track down the culprit for the 800732EE2 errors. We verify all FedEx ground shipping addresses by making a call to the FedEx API when we print the packing slips. Our Priority Mail vendor, Endicia, will not let us print a label with an invalid address. FedEx Express packages will not print the label with an invalid address. For some reason FedEx allows Ground/Home packages to go out with an invalid shipping address but then they would ding us $11 for each invalid address. I fixed the problem by automatically checking addresses. I don’t know where I got the original code but the timeouts worked for every day except the first printout on Monday morning. On Monday mornings we print a lot of packing slips so the ten second receive timeout did not work.

Why do I get 80072EE2 errors?

msxml3.dll error ‘80072ee2’  
The operation timed out

This means that the site you were trying to parse either could not be found, and the component gave up; or it is taking far too long for the page to finish loading. One way you can avoid this error is to set timeout values that are more conservative, e.g.:

<%  
    url = "http://www.espn.com/main.html"  
    set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
    ‘ resolve, connect, send, receive – in milliseconds 
    xmlhttp.setTimeouts 5000, 60000, 10000, 10000 
    xmlhttp.open "GET", url, false  
    xmlhttp.send ""  
    Response.write xmlhttp.responseText  
    set xmlhttp = nothing  
%>

The four timeout values are as follows: 
ResolveTimeout
This value is for the return of a DNS resolution (mapping the domain name to its representative IP address). The default value is infinite. 
ConnectTimeout
This value is for establishing a connection with the server, and the default value is 60 seconds. 
SendTimeout
This value is the time allowed for sending an individual packet of data to the server. The default value is 30 seconds. 
ReceiveTimeout
This value is the time allowed for receiving an individual packet of data from the server. The default value is 30 seconds.

Why do I get 80072EE2 errors?