link to netboffin homepage

Amazon ItemSearch in VB.net with SOAP

Using the Amazon ItemSearch Operation using a SOAP request with VB.NET isn't too complicated once you understand the basic process and data types.
  1. Get the WSDL file for the web service and create a web reference with the web reference tool
  2. Use the object created by the web reference tool to send the request
  3. Get the results
  4. Display the results

Now at version 4.0, the Amazon services require a subscription ID that you must pass with all requests to the service. In this way, your usage is monitored and restrictions can be applied to those who mis-use the service.

  1. Subscription is the first, essential step that will enable you to use Amazon services, so be sure to register and receive your subscription ID.
Imports WebService1.com.amazon.webservices
Imports System.Web
Imports System.Web.Services
 
Public Class Form1
    Private Sub RunQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunQuery.Click
        Dim search As New ItemSearch()
        Dim aws As New AWSECommerceService()
        Dim itemSearchRequest As New ItemSearchRequest()
        itemSearchRequest.Keywords = "PHP OOP"
        itemSearchRequest.SearchIndex = "Books"
        itemSearchRequest.ResponseGroup = New String() {"ItemAttributes"}
        itemSearchRequest.ItemPage = "1"
 
 
        search.AWSAccessKeyId = "<your appid>"
        search.MarketplaceDomain = ""
        search.SubscriptionId = "<your appid>"
        search.Request = New ItemSearchRequest(0) {itemSearchRequest}
        Try
 
            Dim response As ItemSearchResponse = aws.ItemSearch(search)
            Dim itemsResponse As Items() = response.Items
 
 
            If itemsResponse Is Nothing Then
 
                System.Console.Out.WriteLine("No Results")
            End If
            Dim items As Items = itemsResponse(0)
            Dim results As Item() = items.Item
            For Each item As Item In results
                System.Console.Out.WriteLine(item.ItemAttributes.Title)
            Next
        Catch ex As Exception
            System.Console.Out.WriteLine(ex.ToString)
 
        End Try
    End Sub
End Class
Image of an Amazon Web Service Search Result