Menu:

Sponsor

Place your advertising here
casininio casino online casino online Buy and sell flash files

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Using webService with Flash and nuSoap

(Create a search engine using the Amazon web services)

1. Introduction

1.1 What is a Web Service?

Directly from webservices.org: "Web services are self-contained business functions that operate over the Internet. They are written to strict specifications to work together and with other similar kinds of components. Some of the more established functions at this stage are messaging, directories of business capabilities, and descriptions of technical services. But other functions are in the works as well.

Web services are important to business because they enable systems in different companies to interact with each other, more easily than before. With businesses needing closer cooperation between suppliers and customers, engaging in more joint ventures and short-term marketing alliances, pursuing opportunities in new lines of business, and facing the prospect of more mergers and acquisitions, companies need the capability to link up their systems quickly with other companies. Thus Web services give companies like ours the capability do more business electronically, with more potential business partners, in more and different ways than before, and at reasonable cost.

Because Web services are written according to standards, all parties work from the same basic design. Companies then add value and business advantage to the basic design to meet the needs of their customers. For example, a company can offer its suppliers the capability to view inventory levels of products the suppliers provide so they can replenish the stocks without the customer cutting separate purchase orders. Web services provide the basic messaging and service-description functions for this kind of electronic relationship, but the suppliers could build on these basic features to provide better services to the customer. And companies can extend these capabilities to other trading partners, since they are built on standards.

Also, because Web services are built on standards, they make it possible for many systems developers to enter the market, which increases competition and brings down the costs. The competition among vendors also encourages more innovation in the products and services offered to business customers. And basing systems on standards helps prevent being locked-in to a specific vendor or type of computer or software.

Web services are still a work in progress. Some of the standards are still new and not fully tested, and many of the potential business uses are still getting started. But companies should start planning for Web services, and asking vendors for their plans to support Web services." [Read more]

1.2. What is SOAP?

From the W3C specification page: "SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses. SOAP can potentially be used in combination with a variety of other protocols; however, the only bindings defined in this document describe how to use SOAP in combination with HTTP and HTTP Extension Framework." [Read more]

You can also read in depth the WSDL under W3C in conjunction with SOAP

SOAP messages are fundamentally one-way transmissions from a sender to a receiver, but as illustrated above, SOAP messages are often combined to implement patterns such as request/response.

NuSOAP for PHP: what is it?
"NuSOAP is a rewrite of SOAPx4, provided by NuSphere. NuSOAP is a group of PHP classes that allow developers to create and consume SOAP web services. It does not require any special PHP extensions, which makes it usable by all PHP developers, regardless of ISP, server or platform. Beware, I haven't gotten usage of PHPDoc quite right, so the API docs are a bit wonky at this point. NuSOAP is licensed under the LGPL." [ Reference Page ]

Another Guide to soap and nusoap is available at this page

2. Start Up

2.1 What we are going to create.

Amazon associates have the possibility to use the amazon web services to integrate Amazon.com features and content seemlessly into their Web site. If you need more information you can found it at this address .

Note: You need to join the associates amazon program to build your own application with amazon web service.

Ok, before start the tutorial let's take a look at what you need:

  • Join the associate amazon program and get your KEY for the web service
  • Download nusoap for PHP.
  • check your PHP.ini installation and be sure that allow_url_fopen is set to On (1).

Once downloaded nusoap and web service kit create a new folder under your remote site (e.g: soap).
In that folder copy the folder you found in nusoap installation .zip
Copy there also the file "AmazonSearch.php" you can find in the web service kit downloaded from Amazon.com

Now you should have this scenario:

  • soap (main dir)
    • nusoap (nusoap dir)
  • amazonSearch.php

Now you're ready to create this application with Flash MX and PHP

 

2.2 Create the soapClient

Ok, now we have to build a new php page (soapClient.php) in the main directory fo your soap aplication (see above)
The first thing to do is to include the amazonSearch.php page and change the time limit to infinite, this because search can require many time to receive an answer.

The file soapClient.php will start in this way:

<?php
set_time_limit(0);
require("AmazonSearch.php");

Next I create a new variable where i put the nusoap path (i will explain it later):

$soap_path = "nusoap/";

And now, before creating the client we have to declare the variables it needs to work:

// --------------------------
// declare variables for
// web service
// --------------------------
$Tag = 'your_code_as_associate';
$Token = 'your_webservice_key';
$DoHeavySearch = true;
$PrintAll = true;
$Debug = false;
$SearchType = 'heavy';

The $Tag variable is your associate nickname at amazon.com, you will get that at the registration to the associates program.
$Token, instead, is the KEY code which amazon will give you once you apply yourself to the webservice program (you can find the link into the associate pages)
The others variable are "options" for the soap client and thay tell to the amazo web search which kind of search we want to do and also if we want back a Debug output (it will print in output all the variables returned and your enetered parameters too)