Amazon アソシエイト プラグイン ver 1.4.0 for Windows Live Writer

Product Advertising APIという記事で書いたように、AmazonのWebサービスのアクセスが変更されたので、それに対応した、Amazon アソシエイト プラグイン ver 1.4.0 for Windows Live Writerを公開する。

ダウンロードはこちら(Version 1.4.0) 2009/08/20 緊急公開中止。ぜんぜん動かないことが発覚しました。

古いバージョンをお使いの方は、コントロールパネルのプログラムの追加と削除から、「Amazon Associate JP Live Writer Plug In」を削除してから、インストールしてください。

参考にしたサンプルコードはここからダウンロードできる。

このコードをじっくり読むと、Hmac形式で認証する方法と、X509を使って認証する方法と二つの方法が記載されている。

//——————————————————————————
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3053
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//——————————————————————————

//
// WseWsdl3
//
namespace AmazonProductAdvtApi {
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Serialization;
    using Microsoft.Web.Services3;
    using Microsoft.Web.Services3.Messaging;

AmazonProductAdvtApi.csのコードの頭には上のように書かれている。

このSOAPアクセスのコードは自動生成されたもののようだ。WseWsdl3ってなんやねん。Microsoft.Web.Services3ってなんやねん。

ぐぐってみると、WseWsdl3とMSDNに説明がある。このツールは、Web Services Enhancements (WSE) 3.0 for Microsoft .NETに含まれているらしい。

Prerequisites

あぁ、サンプルコードのREADME.htmlにも書かれてるわ。Microsoft Web Services Enhancements 3.0使ってるって書かれてる。

Microsoft.Web.Services3ってどうなってんのん?参照のところにもでてこーへんし。

<Reference Include=”Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL” />

てなコードをプロジェクトの*.csprojの<ItemGroup></ItemGroup>の中にいれてVisual Studioを起動したら、コンパイルが通った。ちうことは、僕の環境には、前から入ってたのね。どこで入ったんだろう。Web Services Enhancements (WSE) 3.0 for Microsoft .NETなんて入れたことないのに。

WseWsdl3で、プロキシコードを生成してくれる模様。

README.htmlには、

About this Sample

  • Based on the 2009-03-31 API version.

ということで、最新版じゃないかもしれないので、生成しなおす。Web Services Enhancements (WSE) 3.0 for Microsoft .NETをダウンロードしてインストールしてみると、C:Program FilesMicrosoft WSEv3.0ToolsにちゃんとWseWsdl3.exeがありました。

C:Program FilesMicrosoft WSEv3.0Tools>WseWsdl3.exe http://webservices.amazon.co.jp/AWSECommerceService/AWSECommerceService.wsdl /o:C:****AWSECommerceService.cs
Web Services Enhancements 3.0 for Microsoft .NET.
Copyright (c) Microsoft Corporation.

Finished processing WSDL file. Proxy written to : C:****AWSECommerceService.cs

C:Program FilesMicrosoft WSEv3.0Tools>

てな感じで生成できる。

/**********************************************************************************************
* Copyright 2009 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the “License”). You may not use this file
* except in compliance with the License. A copy of the License is located at
*
*       http://aws.amazon.com/apache2.0/
*
* or in the “LICENSE.txt” file accompanying this file. This file is distributed on an “AS IS”
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under the License.
*
* ********************************************************************************************
*
*  Amazon Product Advertising API
*  Signed Requests Sample Code
*
*  API Version: 2009-03-31
*
*/

サンプルコードの頭にはこんなで感じで書かれている。ちっ。Apache Licenseか。ちうことで、ざくざく書きなおす。と言ってもまあ構造は変わらへんけどね。

秘密鍵は結局、プログラムの中に埋めちゃった。ま、もちろん簡単に暗号化はしてあるけど。。。

心配なのは、依存関係。Microsoft.Web.Services3って普通はいっているものなのかなあ。。。

「Amazon アソシエイト プラグイン ver 1.4.0 for Windows Live Writer」への1件のフィードバック

  1. Windows Live Writer プラグイン Amazon Associate JPのアップデート の続き

    前回の記事 Windows Live Writerプラグイン Amazon As…

ono ono ono へ返信するコメントをキャンセル

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください