Archive for December, 2007

770Part IVConnectionsProject: A SOAP Server and ClientHere we (Web site designers)

Monday, December 31st, 2007

770Part IVConnectionsProject: A SOAP Server and ClientHere we have an extremely simple SOAP service and a matching client script. XML-RPC and SOAP Web services have two major parts: the actual programming logic andthe mechanism by which the program is exposed or turned into a Web service. The latterincludes tasks such as encoding the request from a function to XML, actually sending therequest as an HTTP POST, and decoding the response. In Perl, this is accomplished by using apackage such as SOAP::Lite. Server-side Java programmers often use the Apache SOAPtoolkit (aka Axis). ASP now uses the .NET framework. PHP offers basic XML-RPC and SOAP functions in its XML-RPC extension, but leaves it todevelopers to come up with bundles of higher-level functionality. There is a SOAP package inthe PEAR extension, but that can be a bit difficult for Windows users to get. Another packagethat is easy to use and widely deployed is NuSOAPby Dietrick Ayala, which you can find athttp://dietrich.ganx4.com/nusoap/index.php. You must have already compiled PHP with the –with-xmland –with-xmlrpcflags. Thengrab NuSOAP(which is composed of just two PHP files), and unzip it in the same directory asthese scripts. The only problem with NuSOAPis that it completely insulates the PHP developer from anyknowledge of what exactly is going on behind the scenes, since it efficiently translates SOAPresponses into native PHP types and vice versa. However, relatively few people care about theactual mechanics of SOAP serialization, and the vocabulary is becoming less human-readableall the time, so we think most PHP developers will be content with learning the basics of creat- ing and consuming RPC services. This Web service basically distributes recipes. Any client can come along and request a par- ticular recipe via SOAP. The recipes themselves happen to be written in XML, but that doesn tmatter they could just as easily be in HTML, plain text, or whatever. After you have therecipe data, you can do whatever you want with it format it for display in a Web page, use itin an XML application, or (as we chose to do in our client) write out a shopping list that wecan print later. Listing 41-3 is a sample recipe that lives on the server: Listing 41-3:Sample XML recipe (mapo_tofu.xml) Mapo tofu 1 T peanut oil 2 oz minced pork 14 oz firm tofu, cut in cubes 2 T garlic chili paste 1 T black bean paste 1 T sherry 1 T rice vinegar 10 oz frozen peas and carrots 1 T. chopped green onion Brown the pork in the peanut oil. Add all the rest46
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

769Chapter 41Web Services076454716X.01.MZZZZZZZ.jpg http://images.amazon.com/images/P/ 076454716X.01.LZZZZZZZ.jpg THIS TITLE IS (Web hosting support)

Sunday, December 30th, 2007

769Chapter 41Web Services076454716X.01.MZZZZZZZ.jpg http://images.amazon.com/images/P/ 076454716X.01.LZZZZZZZ.jpg THIS TITLE IS CURRENTLY NOT AVAILABLE. Ifyou would like to purchase this title, we recommend that youoccasionally check this page to see if it has becomeavailable. $39.99 $39.99 $15.00 The result of the REST client script is shown in Figure 41-1. Figure 41-1:REST client gets XML and outputs HTML. As you can see from the XML sample, there is a lot of potential data from the Web servicethatwe didn t use suggested price, release date, and so on. This demonstrates how easy itis to pick out just the data you want from the feed using DOM XML. According to the currentAmazon Web services rules, you could poll its Web service for fresh XML every second, soyou could keep this part of your information very fresh.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

768Part IVConnectionsListing 41-2(continued) name= KeywordSearch > 2 1 0764549553 PHP (Web hosting company)

Saturday, December 29th, 2007

768Part IVConnectionsListing 41-2(continued) name= KeywordSearch > 2 1

0764549553 PHP Bible, 2nd Edition Book Tim Converse Joyce Park 11 September, 2002 John Wiley & Sons http://images.amazon.com/images/P/ 0764549553.01.THUMBZZZ.jpg http://images.amazon.com/images/P/ 0764549553.01.MZZZZZZZ.jpg http://images.amazon.com/images/P/ 0764549553.01.LZZZZZZZ.jpg Usually ships within 24 hours $49.99 $34.99 $24.49
076454716X PHP 4 Bible Book Tim Converse Joyce Park 17 August, 2000 John Wiley & Sons http://images.amazon.com/images/P/ 076454716X.01.THUMBZZZ.jpg http://images.amazon.com/images/P/
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

767Chapter 41Web Servicesbackground: #FFFFFF; (Web server type) border: 4px solid #008000;

Saturday, December 29th, 2007

767Chapter 41Web Servicesbackground: #FFFFFF; border: 4px solid #008000; width: 200px; /* ie5win fudge begins */ voice-family: } ; voice-family:inherit; width: 200px; } html>body #content { width: 170px; /* ie5win fudge ends */ } p { font-family: Verdana, Arial, sans-serif; font-size: 12px; line-height: 22px; margin-top: 3px; margin-bottom: 2px; }


$title
$author
$price

EONICEBOX; echo $box_str; ?> Those of you who do not have Amazon Associates accounts can use Listing 41-2 for testing, which you should save as phpbible.xmlsomewhere under your Web tree. Listing 41-2:XML sample (phpbible.xml) In case you need quality webspace to host and run your web applications, try our personal web hosting services.

766Part IVConnectionsListing 41-1(continued) // Load up the xml (Sex offenders web site)

Friday, December 28th, 2007

766Part IVConnectionsListing 41-1(continued) // Load up the xml file into memory$dom = new DomDocument; if (!$dom->load($writefile)) { echo Cannot load XML file ; exit; } // Get an immediately available edition$editions = $dom->getElementsByTagname( Availability ); foreach ($editions as $edition_obj) { if ($edition_obj->nodeValue == Usually ships within 24hours ) { // Get the data for this book$book_array = array(); $parent_node = $edition_obj->parentNode; $book_array[ Details ] = $parent_node->getAttribute( url ); $children = $parent_node->childNodes; foreach($children as $child_obj) { $node_name = $child_obj->nodeName; if ($node_name != #text ) { $content_str = $child_obj->nodeValue; $book_array[ $node_name ] = $content_str; } } continue; } else { // Give a message if availability isn t good$book_array[ ProductName ] = Not available at this time ; } } //print_r($book_array); $title = $book_array[ ProductName ]; $author = $book_array[ Authors ]; $image = $book_array[ ImageUrlSmall ]; $detail_page = $book_array[ Details ]; $price = $book_array[ OurPrice ]; // Format a nice box$box_str = <<< EONICEBOX