soap proxy

soap proxy

Note that while services such as Google and PEAR SOAP are technically still in beta, so you can find the odd mistake from time to time. Other SOAP client libraries available, including the PHP5 SOAP extension and NuSOAP, and while implementation details are different, the basic theory is the same as that presented here.

Setting the PEAR SOAP module

Before we can start using SOAP, it is better to make sure both PEAR itself itself and the SOAP module are available. The PEAR package manager is installed by default with PHP 4.3.0 and later, but if you are using an earlier version or not in the system check the PEAR manual.

Once you've installed the package manager will have to download the SOAP package. In the most systems, you can just enter pear install SOAP into a console window. At least that's the theory. Unless you have a stable version of SOAP available, receive the message in any stable release with state equal to that found for SOAP. Beta pear install SOAP try to get the most current version of the package at the time of writing, although it is in beta, or tell PEAR to accept without complaint beta, beta type set pear config preferred state.

Also can obtain one or more messages from package requires, followed by the dependencies. In this case, try the pear install command again but add the dependencies from the command line. For example, if PEAR complained that the net DIME package is missing, try using pear install net DIME instead of SOAP.

How a license key

Once you have installed the SOAP module, the next step is to download the Google Web API Developers Kit and register for a license key. This button allows you to make up to 1000 SOAP requests per day for free. Visit Google web apis www.google.co.uk HTTP API and follow the instructions on the site.

Extracting the developer kit and put it in a convenient location. It contains samples for accessing the service. NET and Java, but most of the documentation that applies equally to call Google from PHP.

Decoding the WSDL file

In the developer kit main directory is called GoogleSearch.wsdl a WSDL file, which can be opened in a text editor or XML browser. This file defines exactly what services we can call using SOAP, but documentation from Google is probably easier to read.

However, we can also see what the SOAP module makes of this file. Create a new PHP page and enter the following.

We once SOAP Client.php
WSDL SOAP WSDL GoogleSearch.wsdl.
Content-Type text plain
generateProxyCode echowsdl.

Put it somewhere on your server along with GoogleSearch.wsdl and access through your web browser. Assuming that everything is working right, you should get a lot of output in php. This code is the result of the Customer class to analyze the SOAP WSDL WSDL file and convert it to PHP functions. This tells us what we can call functions in a rather more readable than the WSDL document, and is especially useful if you are using a WSDL service poorly documented.

So how does the code let s go through it, step by step.

1. In First, load the SOAP client. If this gives an error, it probably means SOAP isn't installed correctly and you should read the instructions above or PEAR Manual.

2. Then create an instance of the class of SOAP WSDL based on GoogleSearch.wsdl file. This is one of the main classes we will use throughout this tutorial analyzes the WSDL file and represents as PHP.

3. Finally, the proxy output code as plain text. As seen in the output SOAP proxy is a class that represents the WSDL calls available as PHP functions.

Spell check with Google

If you've been using Google for a while and the guy that erratically like me, you probably noticed You mean the line that appears if you misspell a word in a search. Thanks to Google's web service, we can add this spell checker for our PHP applications but to be honest, it would probably be better to use pspell in a real application. Enter the following code, with its own license key as the first string.

, T Simple is not the first line is trivial and the following two are the same that the above example. The fourth line creates the proxy object based on the code we've seen, so you can make SOAP requests by calling its methods. Finally, we call doSpellingSuggestion and output the result. Accessing this page in your web browser, and you should see the word in the dictionary on their own.

You may see instead of objects, in which case SOAP has encountered a problem and returns a SOAP fault. We look to address these failings in the future, but for now check whether you entered the license key correctly and not managed to fill its 1000 queries per day limit.

About the Author:

Did you find this article useful? For more useful tips and hints, points to ponder and keep in mind, techniques, and insights pertaining to Internet Business, do please browse for more information at our websites.
http://www.allhottips.com
http://www.bookstoretoday.com

Article Source: ArticlesBase.comIntroduction to Web services with PHP5 SOAP

AWZ – Deniz & Roman – Episode 761 (English Subtitles)