<cfset signStr2 = "Action=SubmitFeed&FeedType=_POST_PRODUCT_PRICING_DATA_">
<cfsavecontent variable="prodXML"><?xml version="1.0" encoding="iso-8859-1" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>#this.merchantID#</MerchantIdentifier>
</Header>
<MessageType>Price</MessageType>
<Message>
<MessageID>1</MessageID>
<Price>
<SKU>#arguments.sku#</SKU>
<StandardPrice currency="USD">#NumberFormat(arguments.price, "_.__")#</StandardPrice>
</Price>
</Message>
</AmazonEnvelope>
</cfsavecontent>
<cfset var gn = GenerateSignedAmazonURL('POST', 'mws.amazonservices.com', '/', signStr2)>
<cfhttp url="#gn#" method="post" useragent="1SmartSolution MWS Component/1.0 (Language=ColdFusion; Platform=Windows/2003)">
<cfhttpparam name="Content-Type" type="header" value="text/xml; charset=iso-8859-1">
<cfhttpparam name="FeedContent" type="body" value="#prodXML#">
<cfhttpparam type="header" name="Content-MD5" value="#ToBase64(BinaryDecode(Hash(prodXML), 'hex'))#">
</cfhttp>
Hope it helps.<cfset signStr2 = "Action=SubmitFeed&FeedType=_POST_PRODUCT_PRICING_DATA_">Where Actionis set to the needed method and is followed by any other required parameters as being FeedTypefor SubmitFeedmethod.
First things you are going to need when dealing with MWS is signature generation. Bellow are the functions i use for it:
<cffunction name="HMAC_SHA256" returntype="binary" access="public" output="false">
<cfargument name="signMessage" type="string" required="true">
<cfset var jMsg = JavaCast("string", arguments.signMessage).getBytes("UTF-8")>
<cfset var jKey = JavaCast("string", this.theSecretAccessKey).getBytes("UTF-8")>
<cfset var key = createObject("java", "javax.crypto.spec.SecretKeySpec")>
<cfset var mac = createObject("java", "javax.crypto.Mac")/>
<cfset key = key.init(jKey, "HmacSHA256")>
<cfset mac = mac.getInstance(key.getAlgorithm())>
<cfset mac.init(key)>
<cfset mac.update(jMsg)>
<cfreturn mac.doFinal()>
</cffunction>
<cffunction name="GenerateSignedAmazonURL" returnType="string" output="yes">
<cfargument name="HTTPVerb" required="yes">
<cfargument name="HostHeader" type="string" required="yes">
<cfargument name="HTTPRequestURI" type="string" required="yes">
<cfargument name="RawQueryString" type="string" required="yes">
<cfset var signature = "">
<cfset var encodedQueryString = "">
<cfset var sortedQueryString = "">
<cfset var encodedSignature = "">
<cfset var name = "">
<cfset var value = "">
<cfset var i = "">
<!--- get your timestamp--->
<cfset var thenow = DateConvert("local2Utc", Now())>
<cfset var time_stamp = "#DateFormat(thenow,'yyyy-mm-dd')#T#TimeFormat(thenow,'HH:mm:ss')#.00Z">
<!--- append timestamp to query string --->
<cfset arguments.RawQueryString = arguments.RawQueryString & "&Marketplace=#this.marketplaceID#">
<cfset arguments.RawQueryString = arguments.RawQueryString & "&Merchant=#this.merchantID#">
<cfset arguments.RawQueryString = arguments.RawQueryString & "&SignatureMethod=HmacSHA256">
<cfset arguments.RawQueryString = arguments.RawQueryString & "&SignatureVersion=2">
<cfset arguments.RawQueryString = arguments.RawQueryString & "&Timestamp=#time_stamp#">
<cfset arguments.RawQueryString = arguments.RawQueryString & "&Version=2009-01-01">
<!--- start building signature --->
<cfset signature = arguments.HTTPVerb & Chr(10)>
<cfset signature = signature & LCase(arguments.HostHeader) & Chr(10)>
<cfset signature = signature & arguments.HTTPRequestURI & Chr(10)>
<!--- loop over the list and urlEncode each value --->
<cfloop list="#arguments.RawQuerySTring#" delimiters="&" index="i">
<cfset name = ListGetAt(i, 1, "=")>
<cfset value = "">
<!--- if this item has a value encode it --->
<cfif ListLen(i, "=") gt 1>
<cfset value = Replace(Replace(Replace(ListGetAt(i, 2, "="), ",", "%2C", "ALL"), ":", "%3A", "ALL"), " ", "%20", "ALL")>
</cfif>
<!--- build the new query string with encoded values --->
<cfset encodedQueryString = ListAppend(encodedQueryString, "#name#=#value#", "&")>
</cfloop>
<!--- next we need to canonically order the queryString params --->
<cfset sortedQueryString = ListSort(encodedQueryString, "textnocase", "asc", "&")>
<!--- append to the signature --->
<cfset signature = signature & "AWSAccessKeyId=#this.accessKeyId#&" & sortedQueryString>
<!--- encode the signature --->
<cfset encodedSignature = URLEncodedFormat(ToBase64(HMAC_SHA256(signature)))/>
<cfreturn "https://#arguments.HostHeader##arguments.HTTPRequestURI#?AWSAccessKeyId=#this.accessKeyId#sortedQueryString#&Signature=#encodedSignature#">
</cffunction>The original version of GenerateSignedAmazonURLi found somewhere time ago when working with AWS and i think i slightly changed it.
The call would be like this:
<cfset generatedURL = GenerateSignedAmazonURL('POST', 'mws.amazonservices.com', '/', signStr2)>A thing to note:POSTin generatedURL should go with POSTtype CFHTTPsand use GETin generatedURL for GETtype CFHTTPs.
I had some headache with it lately, so hope this post will help someone else.
Related Categories: ColdFusion
First, right after i installed it, i started to get "The DataSource service is not available" errors when trying to load ColdFusion Admin and if trying to open one of the sites, was getting errors about related Datasource not existing. I tried starting/stopping/restarting services. I tried to check the size of "neo-*.xml" files. I tried to restart the server itself. I tried anything that came in my mind at that moment, but NOTHING helped.
Then i tried to reinstall this Update. (yes, without to taking down the previous try). Weird, but that error went away. And i was able to get into ColdFusion Administrator without problems. But started to get other errors when trying to load a site on the server: "The tag handler query does not have a setter for the attribute ormOptions specified in the Tag Library Descriptor" and it was pointing to lines where CreateObject being used first time. And again, i wasn't able to find a solution to it.
Then i found this link and used the process described there as "Uninstall Update 1 from a ColdFusion 9 server configuration on Windows". And yes, did try to restart services AND the server itself, but again without any success.
So, after pulling off my hair for some time, i just uninstalled ColdFusion and installed it from scratch but this time without the Update.
It was far from being my first ColdFusion related installation, but it was indeed a total nightmare.
Related Categories: ColdFusion
Area |
What?s new and changed |
Language |
Support for the following:
The following script functions have been implemented as CFCs:
|
Caching
|
The following enhancements:
|
IIS 7 |
IIS 7 configuration for ColdFusion has no dependency on IIS 6 Metabase compatibility. |
Ajax |
The following enhancements:
Added the following JavaScript Functions:
|
ORM |
You can use multiple data sources for ORM in ColdFusion applications. Also, the following enhancements:
|
Amazon S3 Support |
ColdFusion customers can now store data in Amazon S3. |
SpreadSheet |
Support for the following:
|
AIR integration
|
The following enhancements:
|
Flash Remoting |
A channel-definition construct has been introduced in services-config.xml (CF_root/wwroot/WEB-INF/flex/) named serialize-array-to-arraycollection. |
BlazeDS 4 and LCDS |
Support for the following:
|
Solr
|
Apart from overall improvement in the accuracy of indexing, the following enhancements:
|
Logging
|
The following enhancements:
|
Server Monitoring
|
Enhancements in this release help you use Server Monitoring effectively in load conditions. ColdFusion Administrator has the following monitoring options: Enable monitoring, Enable profiling, and Enable memory tracking. |
Configurable seed for password encryption |
Option to specify a new seed value to encrypt data source passwords |
OEM upgrades
|
The following versions are supported:
|
Other enhancements
|
|
Related Categories: ColdFusion, My Projects
Anyway, enough talking. For those interested, here is the link. Note that this is also available now through the JOBS HEAT MAPtop menu link.

