WordpressClient.php

<?php
 
// PHP classes corresponding to the data types in defined in WSDL
 
class getPosts {
 
}
 
class Posts {
 
    /**
     * @var array[0, unbounded] of (object)postType
     */
    public $post;
 
}
 
class postType {
 
    /**
     * @var string
     */
    public $title;
 
    /**
     * @var string
     */
    public $content;
 
    /**
     * @var dateTime
     */
    public $date;
 
}
 
// define the class map
$class_map = array(
    "getPosts" => "getPosts",
    "Posts" => "Posts",
    "postType" => "postType");
 
try {
 
    // create client in WSDL mode
    $client = new WSClient(array ("wsdl" =>"http://ws.dimuthu.org/blog/WordpressService.php?wsdl",
        "classmap" => $class_map));
 
    // get proxy object reference form client 
    $proxy = $client->getProxy();
 
    // create input object and set values
    $input = new getPosts();
    //TODO: fill in the class fields of $input to match your business logic
 
    // call the operation
    $response = $proxy->getPosts($input);
    //TODO: Implement business logic to consume $response, which is of type Posts
 
    if(is_array($response->post)) {
        foreach($response->post as $post) {
            echo "<h2>".$post->title . " - ".$post->date."</h2>\n";
            echo "<p>\n";
            echo $post->content."\n";
            echo "</p>\n";
 
            echo "<hr/>\n\n\n";
        }
    }
 
} catch (Exception $e) {
    // in case of an error, process the fault
    if ($e instanceof WSFault) {
        printf("Soap Fault: %s\n", $e->Reason);
    } else {
        printf("Message = %s\n", $e->getMessage());
    }
}
?>