770Part IVConnectionsProject: A SOAP Server and ClientHere we (Web site designers)
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)
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.