client->ClientName); $client_config = new GetClientConfigResponse(); // getting the BS configured for the client $query = "SELECT bs FROM clienttobs WHERE client = '" . $client . "'"; $result = $db->ExecuteQuery($query); $bs = ''; // hold the BS corresponding to the input CLIENT if ($result) { $dbval = $db->GetSQLValue($result); $bs = $dbval['bs']; } if ($bs) { $query = "SELECT sec, servicename, url FROM service WHERE servicename = '$bs'"; $result = $db->ExecuteQuery($query); if ($result) { $client_config->GetClientConfigResult = new ClientConfigResponse(); $dbval = $db->GetSQLValue($result); $client_config->GetClientConfigResult->Sec = $dbval['sec']; $client_config->GetClientConfigResult->BSName = $dbval['servicename']; $client_config->GetClientConfigResult->BS = $dbval['url']; } } return $client_config; } /** * Service function GetBSConfig * @param object of GetBSConfig $input * @return object of GetBSConfigResponse */ function GetBSConfig($input) { // NOTE: $input is of type GetBSConfig // NOTE: should return an object of type GetBSConfigResponse $db = GetDatabase(); $bs = addslashes($input->bs->BSName); $bs_config = new GetBSConfigResponse(); if ($bs) { $query = "SELECT ops FROM bstoops WHERE bs = '" . $bs . "'"; $result = $db->ExecuteQuery ( $query ); $ops = ''; // hold the OPS corresponding to the input BS if ($result) { $dbval = $db->GetSQLValue( $result ); $ops = $dbval['ops']; } if ($ops) { $query = "SELECT sec, servicename, url FROM service WHERE servicename = '$ops'"; $result = $db->ExecuteQuery ( $query ); if ($result) { $bs_config->GetBSConfigResult = new BSConfigResponse ( ); $dbval = $db->GetSQLValue( $result ); $bs_config->GetBSConfigResult->Sec = $dbval['sec']; $bs_config->GetBSConfigResult->OPSName = $dbval['servicename']; $bs_config->GetBSConfigResult->OPS = $dbval['url']; $host = ''; if (preg_match ( "/mssql/i", $db->connectionInfo->type )) { $host = preg_split ( "/,/", $db->connectionInfo->server ); } else if (preg_match ( "/mysql/i", $db->connectionInfo->type )) { $host = preg_split ( "/:/", $db->connectionInfo->server ); } $bs_config->GetBSConfigResult->DBHostName = $host [0]; $bs_config->GetBSConfigResult->DBName = $db->connectionInfo->database; $bs_config->GetBSConfigResult->DBPort = $host [1]; } } } return $bs_config; } /** * Service function GetOPSConfig * @param object of GetOPSConfig $input * @return object of GetOPSConfigResponse */ function GetOPSConfig($input) { // TODO: fill in the business logic // NOTE: $input is of type GetOPSConfig // NOTE: should return an object of type GetOPSConfigResponse } /** * Service function SetClientToBS * @param object of SetClientToBS $input * @return object of SetClientToBSResponse */ function SetClientToBS($input) { // NOTE: $input is of type SetClientToBS // NOTE: should return an object of type SetClientToBSResponse $db = GetDatabase(); $client = addslashes($input->clientConfig->Client); $bs = addslashes($input->clientConfig->Bs); $query = "UPDATE clienttobs SET bs = '$bs' WHERE client = '$client'"; $result = $db->ExecuteQuery($query); return new SetClientToBSResponse(); } /** * Service function SetBSToOPS * @param object of SetBSToOPS $input * @return object of SetBSToOPSResponse */ function SetBSToOPS($input) { // NOTE: $input is of type SetBSToOPS // NOTE: should return an object of type SetBSToOPSResponse $db = GetDatabase(); $bs = addslashes($input->bsConfig->Bs); $ops = addslashes($input->bsConfig->Ops); $query = "UPDATE bstoops SET ops = '$ops' WHERE bs = '$bs'"; $result = $db->ExecuteQuery($query); return new SetBSToOPSResponse(); } /** * Service function GetBSLocations * @param object of GetBSLocations $input * @return object of GetBSLocationsResponse */ function GetBSLocations($input) { // NOTE: $input is of type GetBSLocations // NOTE: should return an object of type GetBSLocationsResponse $db = GetDatabase(); $query = "SELECT sec, servicename, url FROM service WHERE servicename LIKE '%_BS'"; $result = $db->ExecuteQuery($query); $locations = new GetBSLocationsResponse(); $locations->GetBSLocationsResult = new ArrayOfServiceLocation(); if ($result) { for ($i = 0; $dbval = $db->GetSQLValue($result); $i++) { $locations->GetBSLocationsResult->ServiceLocation[$i] = new ServiceLocation(); $locations->GetBSLocationsResult->ServiceLocation[$i]->Sec = $dbval['sec']; $locations->GetBSLocationsResult->ServiceLocation[$i]->ServiceName = $dbval['servicename']; $locations->GetBSLocationsResult->ServiceLocation[$i]->ServiceURL = $dbval['url']; } } return $locations; } /** * Service function GetOPSLocations * @param object of GetOPSLocations $input * @return object of GetOPSLocationsResponse */ function GetOPSLocations($input) { // NOTE: $input is of type GetOPSLocations // NOTE: should return an object of type GetOPSLocationsResponse $db = GetDatabase(); $query = "SELECT sec, servicename, url FROM service WHERE servicename LIKE '%_OPS%'"; $result = $db->ExecuteQuery($query); $locations = new GetOPSLocationsResponse(); $locations->GetOPSLocationsResult = new ArrayOfServiceLocation(); if ($result) { for ($i = 0; $dbval = $db->GetSQLValue($result); $i++) { $locations->GetOPSLocationsResult->ServiceLocation[$i] = new ServiceLocation(); $locations->GetOPSLocationsResult->ServiceLocation[$i]->Sec = $dbval['sec']; $locations->GetOPSLocationsResult->ServiceLocation[$i]->ServiceName = $dbval['servicename']; $locations->GetOPSLocationsResult->ServiceLocation[$i]->ServiceURL = $dbval['url']; } } return $locations; } /** * Service function SetServiceLocation * @param object of SetServiceLocation $input * @return object of SetServiceLocationResponse */ function SetServiceLocation($input) { // NOTE: $input is of type SetServiceLocation // NOTE: should return an object of type SetServiceLocationResponse $db = GetDatabase(); $sec = ($input->location->Sec == "true") ? 1 : 0; $sname = addslashes($input->location->ServiceName); $surl = addslashes($input->location->ServiceURL); $query = "SELECT servicename FROM service WHERE servicename = '$sname'"; $result = $db->ExecuteQuery($query); $q2 = ''; $dbval = $db->GetSQLValue($result); if ($result && $dbval['servicename']) { // update $q2 = "UPDATE service SET url = '$surl', sec = $sec WHERE servicename = '$sname'"; } else { $q2 = "INSERT INTO service(servicename, url, sec) VALUES ('$sname', '$surl', $sec)"; } $r2 = $db->ExecuteQuery($q2); return new SetServiceLocationResponse(); } // define the operations map $operations = array( "GetClientConfig" => "GetClientConfig", "GetBSConfig" => "GetBSConfig", "GetOPSConfig" => "GetOPSConfig", "SetClientToBS" => "SetClientToBS", "SetBSToOPS" => "SetBSToOPS", "GetBSLocations" => "GetBSLocations", "GetOPSLocations" => "GetOPSLocations", "SetServiceLocation" => "SetServiceLocation"); // define the actions => operations map $actions = array( "http://apache.org/stonehenge/stocktrader/ConfigServiceService/GetClientConfig" => "GetClientConfig", "http://apache.org/stonehenge/stocktrader/ConfigServiceService/GetBSConfig" => "GetBSConfig", "http://apache.org/stonehenge/stocktrader/ConfigServiceService/GetOPSConfig" => "GetOPSConfig", "ClientToBS" => "SetClientToBS", "BSToOPS" => "SetBSToOPS", "http://apache.org/stonehenge/stocktrader/ConfigServiceService/GetBSLocations" => "GetBSLocations", "http://apache.org/stonehenge/stocktrader/ConfigServiceService/GetOPSLocations" => "GetOPSLocations", "ServiceLocation" => "SetServiceLocation"); // create service in WSDL mode $service = new WSService(array ("wsdl" =>"../resources/wsdl/config_svc.wsdl", "actions" => $actions, "classmap" => $class_map, "operations" => $operations)); // process client requests and reply $service->reply(); ?>