<?php

require_once('tilib.php');
require_once('lib/nusoap.php');

$global_file = false;

// Define the method as a PHP function
// function ProxyToolLaunch($CoreSettings, $ContextualSettings, $ToolSettings) {
// function &OutcomeMessage($OutcomeMessageRequest, $imsx_syncRequestHeaderInfo)

// function OutcomeMessage($OutcomeMessageRequest /* ,  $imsx_syncRequestHeaderInfo */) {
function OutcomeMessage($OutcomeMessageRequest) {

    global $global_session;
    global $global_file;

    LG("\n============ Starting OutComeMessage  ===========\n\n");

    $pathback = getPathBack();
    LG("Path = $pathback\n");

    ob_start(LG);
    echo("OutcomeMessageRequest\n");
    var_dump($OutcomeMessageRequest);
    echo("\n");

    ob_end_clean();

    /*
    	<wsdl:message name="OutcomeMessageResponse">
        	<wsdl:part name="Response" element="tns:OutcomeMessageResponse"/>
        	<wsdl:part name="HeaderInfoResponse" element="tns:imsx_syncResponseHeaderInfo"/>
    	</wsdl:message>

	Note: Response seems Empty - Silly

        <xs:element name="OutcomeMessageResponse">
               	<xs:complexType/>
        </xs:element>

        <xs:complexType name="imsx_ResponseHeaderInfo.Type">
                <xs:annotation>
                    <xs:documentation>
                    </xs:documentation>
                </xs:annotation>
                <xs:sequence>
                    <xs:element ref="tns:imsx_version" minOccurs = "0" maxOccurs = "1"/>
                    <xs:element ref="tns:imsx_messageIdentifier" minOccurs = "1" maxOccurs = "1"/>
                    <xs:element ref="tns:imsx_statusInfo" minOccurs = "1" maxOccurs = "1"/>
                    <xs:element ref="tns:SecurityProfile" minOccurs = "0" maxOccurs = "1"/>
                </xs:sequence>
        </xs:complexType>

       <xs:complexType name="SharedSecretSecurityProfile.Type">
                <xs:annotation>
                    <xs:documentation>
                        This is a SOAP Header extension that is required by the service.
                    </xs:documentation>
                </xs:annotation>
                <xs:complexContent>
                    <xs:extension base="tns:SecurityProfile.Type">
                        <xs:sequence>
                            <xs:element ref="tns:MAC" minOccurs = "1" maxOccurs = "1"/>
                        </xs:sequence>
                    </xs:extension>
                </xs:complexContent>
       </xs:complexType>

    */

    // Produce a reasonable return value
    $retval = 
	array ( 
	     'HeaderInfoResponse' =>
	     array (
               'imsx_version' => '1.0',
               'imsx_messageIdentifier' => 'MID',
               'imsx_statusInfo' => array(
                    'imsx_codeMajor' => 'Major Fred',
                    'imsx_severity' => 'Severe Fred',
                    'imsx_messageRefIdentifier' => 'Message ReFred',
                    'imsx_operationRefIdentifier' => 'Operation Ref Ident - Fred',
		    'imsx_codeMinor' => array (
		        'imsx_codeMinorField' => array (
			     'imsx_codeMinorFieldName' => 'Floyd',
			     'imsx_codeMinorFieldValue' => 'Pink'
		         )
                    ),
                    'imsx_description' => 'The IMSX Description'
                 ) // End of imx_statusInfo
                 ,
		 'SecurityProfile' => array (
                    "SOAP:Implementation" => "SharedSecretSecurityProfile.Type",
                    'SharedSecretSecurityProfile.Type' => array (  // A MinimalOutComeProfile
                        "MAC" => "00:ff:ff:ff:00:00"
                     )
		 )
	      ) // End of HeaderInfoResponse
         ) ;

    ob_start(LG);
    echo("\n------- Return Value --------\n");
    var_dump($retval);
    echo("\n");
    ob_end_clean();

    return $retval;
}

global $debug;

// Turn this on if you want massive debugging on soap_server
// The debug outout shows up on the client (testlaunch.php)
// $debug = 999;

$server = new soap_server("TIROutcomeSyncSingle.wsdl");

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>
