createElement('quote'); $rootNode = $domDoc->appendChild($root); $book = $domDoc->createElement('book'); $chapter = $domDoc->createElement('chapter'); $verse = $domDoc->createElement('verse'); $quotation = $domDoc->createElement('quotation'); $chapterValue = ''; $verseValue = ''; $quotationValue = ''; if ($bookValue == "genesis") { $chapterValue = 3; $verseValue = 19; $quotationValue = "By the sweat of your face shall you get bread to eat, until you return to the ground, from which you were taken; For you are dirt, and to dirt you shall return."; } else if ($bookValue == "exodus") { $chapterValue = 20; $verseValue = 16; $quotationValue = "You shall not bear false witness against your neighbor."; } else if ($bookValue == "leviticus") { $chapterValue = 24; $verseValue = 17; $quotationValue = "Whoever takes the life of any human being shall be put to death."; } else if ($bookValue == "numbers") { $chapterValue = 24; $verseValue = 17; $quotationValue = "When he is fifty years old, he shall retire from the required service and work no longer."; } else if ($bookValue == "numbers") { $chapterValue = 14; $verseValue = 6; $quotationValue = "Any animal that has hoofs you may eat, provided it is cloven-footed and chews the cud."; } else { $chapterValue = ""; $verseValue = ""; $quotationValue = "** ERROR: Invalide book specified in web service call"; } trace("Quotation is " . $quotationValue); $bookTextNode = $domDoc->createTextNode(ucfirst($bookValue)); $book->appendChild($bookTextNode); $chapterTextNode = $domDoc->createTextNode($chapterValue); $chapter->appendChild($chapterTextNode); $verseTextNode = $domDoc->createTextNode($verseValue); $verse->appendChild($verseTextNode); $quotationTextNode = $domDoc->createTextNode($quotationValue); $quotation->appendChild($quotationTextNode); $rootNode->appendChild($book); $rootNode->appendChild($chapter); $rootNode->appendChild($verse); $rootNode->appendChild($quotation); $domDoc->formatOutput = true; return $domDoc->saveXML(); } function trace($message) { $outFile = "bibleWStrace.log"; // write new data to file $fh = fopen($outFile, 'a') or die("can't open file"); // 'w' = overwrite existing file, 'a' = add to file $now = date('Y-m-d H:i:s'); $file = pathinfo(__FILE__); // Get information about this file. fwrite($fh,"\n" . $now .": \t" . $message . " (" . $file['dirname'] . "/" . $file['basename'] . ")"); } $server = new soap_server(); $server->register("getQuote"); $server->service($HTTP_RAW_POST_DATA);