/**
 * Register Image Action Sample
 * The RegisterImage operation registers an AMI with Amazon EC2. Images must be
 * registered before they can be launched. For more information, see RunInstances.
 * Each AMI is associated with an unique ID which is provided by the Amazon EC2
 * service through the RegisterImage operation. During registration, Amazon EC2
 * retrieves the specified image manifest from Amazon S3 and verifies that the
 * image is owned by the user registering the image.
 * The image manifest is retrieved once and stored within the Amazon EC2. Any
 * modifications to an image in Amazon S3 invalidates this registration. If you
 * make changes to an image, deregister the previous image and register the new
 * image. For more information, see DeregisterImage.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_RegisterImage or array of parameters
 */
function invokeRegisterImage(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->registerImage($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        RegisterImageResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetRegisterImageResult()) {
            echo "            RegisterImageResult\n";
            $registerImageResult = $response->getRegisterImageResult();
            if ($registerImageResult->isSetImageId()) {
                echo "                ImageId\n";
                echo "                    " . $registerImageResult->getImageId() . "\n";
            }
        }
    } catch (Amazon_EC2_Exception $ex) {
        echo "Caught Exception: " . $ex->getMessage() . "\n";
        echo "Response Status Code: " . $ex->getStatusCode() . "\n";
        echo "Error Code: " . $ex->getErrorCode() . "\n";
        echo "Error Type: " . $ex->getErrorType() . "\n";
        echo "Request ID: " . $ex->getRequestId() . "\n";
        echo "XML: " . $ex->getXML() . "\n";
    }
}