<?

/************************************************************************
*
*                  OMS Web Service Functions 1.4
*                  -----------------------------
*
*     Copyright:   (C) 2007 moving primates GmbH
*      Function:   GetBandMembers
*   Description:   Gets the band member's name, instrument and e-mail
*                  address of one artist.
*   Change Date:   12/Jun/2007
*
*************************************************************************
*
*   REQUIRED ELEMENTS:
*
*   The following required elements must be send with the request:
*
*   - ArtistID
*   - Fieldlist
*
*   FIELD ELEMENTS:
*
*   The following are Field elements which define what you get back from
*   the Web Service function. They must be named "Field", their value
*   must be the exact name of the following enumeration and they must be
*   created as a child element of "Fieldlist".
*
*   Field elements are optional, however it is required that you
*   create at least one; their send order is irrelevant.
*
*    - MemberName
*   - MemberInstrument
*   - MemberEmail
*
*************************************************************************
*   More info about elements and the functions can be found inside
*   the documentation.
************************************************************************/

$ArtistID = "36268"; // Example ID from an artist
include("inc/config.php"); // Example path, point it to your config.php


$dom = create_document();
$root = create_root_element($dom, "OMS");
create_element_attribute($root, "xmlns", $oms_cfg['artist_data_xmlns'] . "/GetBandMembers");


// Here we are defining the REQUIRED elements

$el_artist_id = create_element($dom, "ArtistID");
set_element_value($dom, $el_artist_id, $ArtistID);


// Here we are defining the FIELDLIST and its elements (requesting all available)

$el_fields_list = create_element($dom, "FieldList");

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "MemberName");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "MemberInstrument");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "MemberEmail");
add_child_element($el_fields_list, $el_field);

add_child_element($root, $el_artist_id);
add_child_element($root, $el_fields_list);


// Preparing the XML which is going to be send

$xml_str = dump_to_string($dom);
$par = array("String_1" => $oms_cfg['ws_login'],
            
"String_2" => $oms_cfg['ws_password'],
            
"String_3" => $xml_str );


// Executing the Web Service function "GetBandMembers"

$GetBandMembers = ProcessWSCall($oms_cfg['artist_data_ws_url'], "GetBandMembers", $par, $oms_cfg['artist_data_xmlns']);                


// Counting available bandmembers

if(isset($GetBandMembers['ArtistID']))
{
    if(isset(
$GetBandMembers['MemberList'][0]['Member']))
    {
        
$bandmember_count = sizeof($GetBandMembers['MemberList'][0]['Member']);
    }
    else
    {
        
$bandmember_count = 0;
    }
}


/************************************************************************
*
*   From here on we assign the content of the array to variables and
*   create some example output. This was done so you can see something
*   when opening the PHP files with your browser.
*
*   If you are looking for this code without any comments or output,
*   then check out the folder 'minimal_code'.
*
************************************************************************/

?>
<style type="text/css">
<!--
.font {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style>
<span class="font"> <strong>We sent the following elements with our <u>REQUEST</u>:</strong><br />
<ul>
    <li><em>ArtistID</em> - value was &quot;36268&quot;, an example ID from an artist</li>
    <li><em>Fieldlist</em> - the requested child elements were: <i>
        <ul>
            <li>MemberName</li>
            <li>MemberInstrument</li>
            <li>MemberEmail</li>
        </ul>
        </i> </li>
</ul>
<br />
<strong>We got back the following array in <u>RESPONSE</u>:</strong><br />
<pre><? var_dump($GetBandMembers); ?>
</pre>
<br />
<strong>We assign the array to  seperate variables and <u>OUTPUT</u> these (without any design here):</strong><br />
<?
    $ArtistID
= $GetBandMembers['ArtistID'][0];
?>
<ul>
    <li>Artist ID: <? echo $ArtistID; ?></li>
</ul>
<ul>
<?
    
for($i=0;$i<$bandmember_count;$i++)
    {
        
$MemberName = $GetBandMembers['MemberList'][0]['Member'][$i]['MemberName'];
        
$MemberInstrument = $GetBandMembers['MemberList'][0]['Member'][$i]['MemberInstrument'];
        
$MemberEmail = $GetBandMembers['MemberList'][0]['Member'][$i]['MemberEmail'];
?>
    <p><strong>Entry No. <? echo $i+1; ?></strong></p>
    <li>Member Name: <? echo $MemberName; ?></li>
    <li>Member Instrument: <? echo $MemberInstrument; ?></li>
    <li>Member Email: <? echo $MemberEmail; ?></li>
    <?
    
}
?>
</ul>
</span>