« BizTalk MQSeries adapter cross domain Authentication | Main | Contract First Development and BizTalk Server »
Wednesday
Aug012012

Amazon Marketplace Web Service (MWS) BizTalk WCF Adapter

Amazon’s Marketplace Web Service (MWS) is a is an integrated Web service API that helps Amazon sellers to programmatically exchange data on listings, orders, payments, reports, and more. XML data integration with Amazon enables higher levels of selling automation, which helps sellers grow their business. By using Amazon MWS, sellers can increase selling efficiency, reduce labor requirements, and improve response time to customers.

The API has some nice documentation, C# libraries and samples you can download from the site.

Basically they give you 8 different interfaces.

  • Orders
  • Feeds
  • Reports
  • Inbound Shipments
  • Outbound Shipments
  • Inventory
  • Products
  • Sellers

Most are self-explanatory.  Feeds and reports enable you to request or schedule a report/data feed to be generated.

MWS and BizTalk

Unfortunately BizTalk doesn’t really support REST at the moment, there are a couple of workarounds but they are a little clunky. I’ve worked with the MWS service in the past and for various reasons we went with a windows service that pulled reports down and submitted the flat files to BizTalk. This worked well and I really learnt a lot about the MWS API’s. I’ve since been thinking about a Custom WCF Adapter. So here it is….

I think there’s great opportunity for larger Amazon sellers that want to integrate with MWS. This could be with existing ERP’s like Dynamics AX, SAP or Oracle eBusiness Suite etc which BizTalk already supports. BizTalk also has strong EDI capabilities so I could imagine integrating vendors\customers with MWS using EDI or RosettaNet. Hopefully this adapter will make that easier and allow firms to leverage a proven middleware platform.

The adapter isn’t really an adapter, strictly speaking it’s a WCF binding but we’ll call it an adapter for simplicity and coolness.

Of the list above currently the Adapter only supports the following interfaces:

  • Orders
  • Inbound Shipments
  • Outbound Shipments
  • Inventory
  • Products
  • Sellers

You’ll notice only Feeds and Reports are missing. Feeds and Reports would make more sense to be a Receive Adapter in my opinion. You have to request the data to be generated, keep checking if it’s ready and then pull down the data and away you go. It still requires more mountain bike thinking time as to the best way to implement it. Currently I’m thinking about developing an interface that the user could select which reports/feeds they want and define a schedule. BizTalk would request the reports and wait (poll) for them to be available, but as I said it requires more thought.

Each API has about 10 or so methods, for example InboundShipment supports the following:

  • CreateInboundShipmentPlan
  • CreateInboundShipment
  • GetServiceStatus
  • ListInboundShipmentItemsByNextToken
  • ListInboundShipmentItems
  • ListInboundShipmentsByNextToken
  • ListInboundShipments
  • UpdateInboundShipment

 

Schemas

With the Adapter you’ll get several DLL’s containing all the Request & Response schemas for the support API’s. For example, InboundShipment:

  • CreateInboundShipmentPlanRequest
  • CreateInboundShipmentPlanResponse
  • CreateInboundShipmentRequest
  • CreateInboundShipmentResponse
  • GetServiceStatusRequest
  • GetServiceStatusResponse
  • ListInboundShipmentItemsByNextTokenRequest
  • ListInboundShipmentItemsByNextTokenResponse
  • ListInboundShipmentItemsRequest
  • ListInboundShipmentItemsResponse
  • ListInboundShipmentsByNextTokenRequest
  • ListInboundShipmentsByNextTokenResponse
  • ListInboundShipmentsRequest
  • ListInboundShipmentsResponse
  • UpdateInboundShipmentRequest
  • UpdateInboundShipmentResponse

In all the schemas I’ve promoted SellerId, MarketPlace and NextToken so these can be populated via property demotion.

Example Request Message, CreateInboundShipmentPlanRequest:

<ns0:CreateInboundShipmentPlanRequest 
xmlns:ns0="http://mws.amazonaws.com/FulfillmentInboundShipment/2010-10-01/">
<ns0:SellerId>SellerId_0</ns0:SellerId>
<ns0:Marketplace>Marketplace_0</ns0:Marketplace>
<ns0:ShipFromAddress>
<ns0:Name>Name_0</ns0:Name>
<ns0:AddressLine1>AddressLine1_0</ns0:AddressLine1>
<ns0:AddressLine2>AddressLine2_0</ns0:AddressLine2>
<ns0:DistrictOrCounty>DistrictOrCounty_0</ns0:DistrictOrCounty>
<ns0:City>City_0</ns0:City>
<ns0:StateOrProvinceCode>StateOrProvinceCode_0</ns0:StateOrProvinceCode>
<ns0:CountryCode>CountryCode_0</ns0:CountryCode>
<ns0:PostalCode>PostalCode_0</ns0:PostalCode>
</ns0:ShipFromAddress>
<ns0:LabelPrepPreference>LabelPrepPreference_0</ns0:LabelPrepPreference>
<ns0:InboundShipmentPlanRequestItems>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:ASIN>ASIN_0</ns0:ASIN>
<ns0:Condition>Condition_0</ns0:Condition>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:ASIN>ASIN_0</ns0:ASIN>
<ns0:Condition>Condition_0</ns0:Condition>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:ASIN>ASIN_0</ns0:ASIN>
<ns0:Condition>Condition_0</ns0:Condition>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
</ns0:InboundShipmentPlanRequestItems>
</ns0:CreateInboundShipmentPlanRequest>
 
Response:
 
<ns0:CreateInboundShipmentPlanResponse 
xmlns:ns0="http://mws.amazonaws.com/FulfillmentInboundShipment/2010-10-01/">
<ns0:CreateInboundShipmentPlanResult>
<ns0:InboundShipmentPlans>
<ns0:member>
<ns0:ShipmentId>ShipmentId_0</ns0:ShipmentId>
<ns0:DestinationFulfillmentCenterId>DestinationFulfillmentCenterId_0
</ns0:DestinationFulfillmentCenterId>
<ns0:ShipToAddress>
<ns0:Name>Name_0</ns0:Name>
<ns0:AddressLine1>AddressLine1_0</ns0:AddressLine1>
<ns0:AddressLine2>AddressLine2_0</ns0:AddressLine2>
<ns0:DistrictOrCounty>DistrictOrCounty_0</ns0:DistrictOrCounty>
<ns0:City>City_0</ns0:City>
<ns0:StateOrProvinceCode>StateOrProvinceCode_0</ns0:StateOrProvinceCode>
<ns0:CountryCode>CountryCode_0</ns0:CountryCode>
<ns0:PostalCode>PostalCode_0</ns0:PostalCode>
</ns0:ShipToAddress>
<ns0:LabelPrepType>LabelPrepType_0</ns0:LabelPrepType>
<ns0:Items>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:FulfillmentNetworkSKU>FulfillmentNetworkSKU_0</ns0:FulfillmentNetworkSKU>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:FulfillmentNetworkSKU>FulfillmentNetworkSKU_0</ns0:FulfillmentNetworkSKU>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:FulfillmentNetworkSKU>FulfillmentNetworkSKU_0</ns0:FulfillmentNetworkSKU>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
</ns0:Items>
</ns0:member>
<ns0:member>
<ns0:ShipmentId>ShipmentId_0</ns0:ShipmentId>
<ns0:DestinationFulfillmentCenterId>DestinationFulfillmentCenterId_0
</ns0:DestinationFulfillmentCenterId>
<ns0:ShipToAddress>
<ns0:Name>Name_0</ns0:Name>
<ns0:AddressLine1>AddressLine1_0</ns0:AddressLine1>
<ns0:AddressLine2>AddressLine2_0</ns0:AddressLine2>
<ns0:DistrictOrCounty>DistrictOrCounty_0</ns0:DistrictOrCounty>
<ns0:City>City_0</ns0:City>
<ns0:StateOrProvinceCode>StateOrProvinceCode_0</ns0:StateOrProvinceCode>
<ns0:CountryCode>CountryCode_0</ns0:CountryCode>
<ns0:PostalCode>PostalCode_0</ns0:PostalCode>
</ns0:ShipToAddress>
<ns0:LabelPrepType>LabelPrepType_0</ns0:LabelPrepType>
<ns0:Items>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:FulfillmentNetworkSKU>FulfillmentNetworkSKU_0</ns0:FulfillmentNetworkSKU>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:FulfillmentNetworkSKU>FulfillmentNetworkSKU_0</ns0:FulfillmentNetworkSKU>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
<ns0:member>
<ns0:SellerSKU>SellerSKU_0</ns0:SellerSKU>
<ns0:FulfillmentNetworkSKU>FulfillmentNetworkSKU_0</ns0:FulfillmentNetworkSKU>
<ns0:Quantity>10.4</ns0:Quantity>
</ns0:member>
</ns0:Items>
</ns0:member>
</ns0:InboundShipmentPlans>
</ns0:CreateInboundShipmentPlanResult>
<ns0:ResponseMetadata>
<ns0:RequestId>RequestId_0</ns0:RequestId>
</ns0:ResponseMetadata>
</ns0:CreateInboundShipmentPlanResponse>
 
To use the MWSAdapter just reference the schema and promoted property DLL’s and configure the send port. Obviously it will be a solicit response send port.

image

 

On the Endpoint Address tab you must configure it as follows:

Address URI: The schema is mws:// then enter the host and port for the MWS API server. The Adapter will only support https so the port isn’t required.

Action: The normal Operation/Action mapping for WCF adapters except the Action must be defined as follows:

[ServiceAPI]/[ServicePath]/[ServiceMethod]

e.g. InboundShipment/FulfillmentInboundShipment/CreateInboundShipmentPlan

The adapter takes the ServiceAPI and loads the appropriate Amazon API library, the ServicePath is used in the URI e.g. https://mws.amazonservices.com:443/FulfillmentInboundShipment/

The ServiceMethod clearly relates to the actual method being called.

Example Action Mapping XML:

<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="createInboundShipmentPlan"
Action="InboundShipment/FulfillmentInboundServiceMWS/CreateInboundShipmentPlan" />
<Operation Name="createInboundShipment"
Action="InboundShipment/FulfillmentInboundServiceMWS/CreateInboundShipment" />
</BtsActionMapping>

image

 

The binding is called mwsAdapter and has the following properties which all relate to your Amazon credentials. The Adapter will use these when it constructs the request message.

image

 

That’s it really, fairly simple. Using BizTalk you can then create your Amazon Request messages as you want depending on what you’re integrating it with.

If you’re interested in using this adapter get in contact with us. I’m still testing at this point so not quite ready to release code just yet.

I’ll post an actual demo of the adapter after I get through some more testing.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>