You are viewing a plain text version of this content. The canonical link for it is here.
Posted to stonehenge-commits@incubator.apache.org by sh...@apache.org on 2008/11/26 10:49:07 UTC
svn commit: r720795 [6/7] - in
/incubator/stonehenge/contrib/stocktrader/php: business_service/
business_service/keys/ business_service/wsdl/ config_service/
config_service/wsdl/ order_processor/ order_processor/keys/ trader_client/
trader_client/image...
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/portfolio.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/portfolio.php?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/portfolio.php (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/portfolio.php Wed Nov 26 02:49:04 2008
@@ -0,0 +1,206 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("request_processor.php");
+if(!IsLoggedIn())
+{
+ header("Location: login.php");
+}
+else
+{
+ $holdings = GetHoldings(GetUserFromCookie());
+ if ($holdings)
+ {
+ $holdingsReturn = $holdings->getHoldingsReturn;
+ }
+}
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+ <meta http-equiv="content-type" content="text/html;charset=utf-8" />
+ <meta name="generator" content="Adobe GoLive" />
+ <title>WSF/PHP StockTrader Welcome</title>
+ <link href="style.css" rel="stylesheet" type="text/css" media="all" />
+ </head>
+
+ <body>
+ <div id="content">
+ <div id="header">
+ <div class="logo"><img src="images/logo.gif"></div>
+ </div>
+ <div id="header-links">
+ <table>
+ <tr>
+ <td>
+ <a href="index.php">Welcome</a>
+ </td>
+ <td>
+ <a href="home.php">Home</a>
+ </td>
+ <td>
+ <a href="account.php">Account</a>
+ </td>
+ <td>
+ <a href="portfolio.php">Portfolio</a>
+ </td>
+ <td>
+ <a href="quotes.php">Quotes/Trade</a>
+ </td>
+ <td>
+ <a href="glossary.php">Glossary</a>
+ </td>
+ <td>
+ <a href="config.php">Config</a>
+ </td>
+ <td>
+ <a href="login.php">Login/Logout</a>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="middle">
+
+ <?php
+ $getClosedOrdersReturn = GetClosedOrders();
+ if ($getClosedOrdersReturn)
+ {
+ print ("<p style=\"color: red\" align=\"center\">Trade Alert: The following orders have completed.</p>");
+ print("<table class=\"table-outer\" cellspacing=\"0\" align=\"center\"><thead>
+ <tr><th>Order ID</th><th>Order Status</th><th>Creation Date</th><th>Completion Date</th>
+ <th>Txn Fee</th><th>Type</th><th>Symbol</th><th>Quantity</th></tr></thead><tbody>");
+
+ $index = 0;
+ while ($getClosedOrdersReturn->OrderDataBean[$index])
+ {
+ $openDate = new DateTime($getClosedOrdersReturn->OrderDataBean[$index]->openDate);
+ $completionDate = new DateTime($getClosedOrdersReturn->OrderDataBean[$index]->completionDate);
+ print ("<tr><td>".$getClosedOrdersReturn->OrderDataBean[$index]->orderID."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->orderStatus."</td>
+ <td>".$openDate->format("m/d/Y h:i:s A")."</td>
+ <td>".$completionDate->format("m/d/Y h:i:s A")."</td>
+ <td>$".$getClosedOrdersReturn->OrderDataBean[$index]->orderFee."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->orderType."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->symbol."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->quantity."</td></tr>");
+ $index ++;
+ }
+ print("</tbody></table><br/><br/>");
+ }
+
+ if ($holdingsReturn)
+ {
+ print ("<div class=\"main-title\">
+ <h1>Portfolio Information</h1><script type=\"text/javascript\">var thisdate = new Date();
+ document.writeln(thisdate.toLocaleString());</script></div>");
+
+ print ("<table class=\"table-outer\" cellspacing=\"0\" align=\"center\">
+ <thead><tr><th>Holding ID</th><th>Purchase Date</th><th>Symbol</th>
+ <th>Quantity</th><th>Purchase Price</th><th>Current Price</th>
+ <th>Purchase Basis</th><th>Market Value</th><th>Gain(Loss)</th>
+ <th>Trade</th></tr></thead><tbody>");
+
+ $index = 0;
+ $purchaseBasis = 0;
+ $marketValue = 0;
+ $gain = 0;
+
+ while ($holdingsReturn->HoldingDataBean[$index])
+ {
+ $bean = $holdingsReturn->HoldingDataBean[$index];
+
+ if (!$quoteInfo[$bean->quoteID])
+ {
+ $quotes = GetQuote($bean->quoteID);
+ if ($quotes)
+ $quotesReturn = $quotes->getQuoteReturn;
+ $quoteInfo[$bean->quoteID] = $quotesReturn->price;
+ }
+
+ $purchaseBasis = $purchaseBasis + ($bean->purchasePrice) * ($bean->quantity);
+ $marketValue = $marketValue + ($quoteInfo[$bean->quoteID]) * ($bean->quantity);
+ $gain = ($quoteInfo[$bean->quoteID] - $bean->purchasePrice) * ($bean->quantity);
+
+ $dateTime = new DateTime($bean->purchaseDate);
+ print("<tr><td>".$bean->holdingID."</td><td><nobr>".$dateTime->format("m/d/Y h:i:s A")."</nobr></td><td>
+ <form action=\"quotes.php\" method=\"post\">
+ <input type=\"hidden\" name=\"SYMBOLS\" value=\"".$bean->quoteID."\"/>
+ <input type=\"submit\" name=\"GETQUOTE\" value=\"".$bean->quoteID."\"></input>
+ </form></td>
+ <td class=\"currency\">".$bean->quantity."</td><td class=\"currency\">$"
+ .$bean->purchasePrice."</td><td class=\"currency\">$".$quoteInfo[$bean->quoteID]."</td><td class=\"currency\">$".
+ (($bean->purchasePrice) * ($bean->quantity))."</td><td class=\"currency\">$".($quoteInfo[$bean->quoteID] * ($bean->quantity)).
+ "</td><td class=\"currency\">");
+
+ if ($gain > 0)
+ {
+ print ("<span class=\"price-gain\">".$gain."</span>");
+ }
+ else if ($gain < 0)
+ {
+ print ("<span class=\"price-loss\">".$gain."</span>");
+ }
+ else
+ {
+ print ("<span>".$gain."</span>");
+ }
+ print("</td><td class=\"currency\">");
+ print("<form action = \"confirmation.php\" method = \"post\">");
+ print("<input type=\"hidden\" name=\"HOLDINGID\" value=\"".$bean->holdingID."\"></input>");
+ print("<input type=\"hidden\" name=\"QUANTITY\" value=\"".$bean->quantity."\"></input>");
+ print("<input type=\"hidden\" name=\"SYMBOL\" value=\"".$bean->quoteID."\"></input>");
+ print("<input type=\"submit\" value = \"Sell\" name=\"SELL\">");
+ print("</input></td></tr></form>");
+
+ $index ++;
+ }
+ print ("<tr class=\"total\"><td colspan=\"6\">Totals</td><td class=\"currency\">$".$purchaseBasis.
+ "</td><td class=\"currency\">$".$marketValue."</td><td>");
+
+ $gain = $marketValue - $purchaseBasis;
+ if ($gain < 0)
+ {
+ print ("<span class=\"price-loss\">$".$gain."</span></td><td></td></tr>");
+ }
+ else if ($gain > 0)
+ {
+ print ("<span class=\"price-gain\">$".$gain."</span></td><td></td></tr>");
+ }
+ else
+ {
+ print ("<span>$".$gain."</span></td><td></td></tr>");
+ }
+ print ("</tbody></table>");
+ }
+ ?>
+ <div class="bottom">
+ <form action = "quotes.php" method = "post">
+ <input type="text" value="" name="SYMBOLS" id="" size="25"/><input type="submit" name="GETQUOTE" value="Get Quote" class="button"/>
+ </form>
+ </div>
+ </div>
+ <div id="footer">
+ <div style="float:left;">Copyright 2008, WSO2 Inc.</div>
+ <div style="margin-left:432px;float:left;">Powered by
+ <img align="top" src="images/powered-by-logo.gif" style="margin-top:-3px; margin-left: 0px;"/></div>
+ </div>
+ </div>
+ </body>
+</html>
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/quotes.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/quotes.php?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/quotes.php (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/quotes.php Wed Nov 26 02:49:04 2008
@@ -0,0 +1,311 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once("request_processor.php");
+
+if(!IsLoggedIn())
+{
+ header("Location: login.php");
+}
+else if($_POST['GETQUOTE'])
+{
+ /*This is a request to get quote information for a particular symbol*/
+ $symbol = $_POST['SYMBOLS'];
+ if ($symbol)
+ {
+ $quotes = GetQuote($symbol);
+ if ($quotes)
+ $quotesReturn = $quotes->getQuoteReturn;
+ }
+}
+else if ($_POST['BUY'] || $_POST['SELL'])
+{
+ /*This is a buy or sell request*/
+ $quantity = $_POST['QUANTITY'];
+ $userID = GetUserFromCookie();
+ $isBuy = FALSE;
+ $isSell = FALSE;
+
+ if ($_POST['BUY'])
+ {
+ $mode = 0;
+ $isBuy = TRUE;
+ $symbol = $_POST['SYMBOL'];
+ $response = Buy($userID, $symbol, $quantity, $mode);
+ if ($response->buyReturn->orderID)
+ {
+ $buyReturn = $response->buyReturn;
+ $isReply = TRUE;
+ }
+ else
+ {
+ $response = NULL;
+ }
+ }
+ else if($_POST['SELL'])
+ {
+ $isSell = TRUE;
+ $holdingID = $_POST['HOLDINGID'];
+ $response = SellEnhanced($userID, $holdingID, $quantity);
+ if ($response->sellEnhancedReturn->orderID)
+ {
+ $sellEnhancedReturn = $response->sellEnhancedReturn;
+ $isReply = TRUE;
+ }
+ else
+ {
+ $response = NULL;
+ }
+ }
+}
+else
+{
+ /*If not above, the user has just wanted to
+ visit the quote page*/
+ $quotesInitialPage = TRUE;
+}
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+ <meta http-equiv="content-type" content="text/html;charset=utf-8" />
+ <meta name="generator" content="Adobe GoLive" />
+ <title>WSF/PHP StockTrader Welcome</title>
+ <link href="style.css" rel="stylesheet" type="text/css" media="all" />
+ </head>
+
+ <body>
+ <div id="content">
+ <div id="header">
+ <div class="logo"><img src="images/logo.gif"></div>
+ </div>
+ <div id="header-links">
+ <table>
+ <tr>
+ <td>
+ <a href="index.php">Welcome</a>
+ </td>
+ <td>
+ <a href="home.php">Home</a>
+ </td>
+ <td>
+ <a href="account.php">Account</a>
+ </td>
+ <td>
+ <a href="portfolio.php">Portfolio</a>
+ </td>
+ <td>
+ <a href="quotes.php">Quotes/Trade</a>
+ </td>
+ <td>
+ <a href="glossary.php">Glossary</a>
+ </td>
+ <td>
+ <a href="config.php">Config</a>
+ </td>
+ <td>
+ <a href="login.php">Login/Logout</a>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="middle">
+
+ <?php
+ $getClosedOrdersReturn = GetClosedOrders();
+ if ($getClosedOrdersReturn)
+ {
+ /*Checking whether there is new status change happened in the
+ related to a particular order.*/
+ print ("<p style=\"color: red\" align=\"center\">Trade Alert: The following orders have completed.</p>");
+ print("<table class=\"table-outer\" cellspacing=\"0\" align=\"center\"><thead>
+ <tr><th>Order ID</th><th>Order Status</th><th>Creation Date</th><th>Completion Date</th>
+ <th>Txn Fee</th><th>Type</th><th>Symbol</th><th>Quantity</th></tr></thead><tbody>");
+
+ $index = 0;
+ while ($getClosedOrdersReturn->OrderDataBean[$index])
+ {
+ $openDate = new DateTime($getClosedOrdersReturn->OrderDataBean[$index]->openDate);
+ $completionDate = new DateTime($getClosedOrdersReturn->OrderDataBean[$index]->completionDate);
+ print ("<tr><td>".$getClosedOrdersReturn->OrderDataBean[$index]->orderID."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->orderStatus."</td>
+ <td>".$openDate->format("m/d/Y h:i:s A")."</td>
+ <td>".$completionDate->format("m/d/Y h:i:s A")."</td>
+ <td>$".$getClosedOrdersReturn->OrderDataBean[$index]->orderFee."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->orderType."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->symbol."</td>
+ <td>".$getClosedOrdersReturn->OrderDataBean[$index]->quantity."</td></tr>");
+ $index ++;
+ }
+ print("</tbody></table><br/><br/>");
+ }
+
+ if ($isReply == TRUE)
+ {
+ /*Check whether the user has requested to buy or sell some quote.*/
+ print ("<div class=\"main-title\"><h1>New Order</h1>
+ <script type=\"text/javascript\">var thisdate = new Date();
+ document.writeln(thisdate.toLocaleString());</script></div>");
+ print ("<p align=\"center\">Order ".$buyReturn->orderID." to
+ ".(($buyReturn->quantity) ? "buy ".($buyReturn->quantity):
+ "sell ".($sellReturn->quantity))." shares of s:0 has been submitted for processing.</p>");
+ print ("<p align=\"center\">Order Details:</p>");
+ print ("<table class=\"table-outer\" cellspacing=\"0\" align=\"center\"><thead><tr>
+ <th>Order ID</th><th>Order Status</th><th>Creation Date</th>
+ <th>Completion Date</th><th>Txn Fee</th><th>Type</th><th>Symbol</th>
+ <th>Quantity</th></tr></thead>
+ <tbody>");
+
+ if ($isBuy == TRUE)
+ {
+ $dateTime = new DateTime($buyReturn->openDate);
+ print ("<tr><td>".$buyReturn->orderID."</td><td>".$buyReturn->orderStatus.
+ "</td><td>".$dateTime->format("m/d/Y h:i:s A")."</td><td>Pending".
+ "</td><td>$".$buyReturn->orderFee."</td><td>".$buyReturn->orderType.
+ "</td><td>".$buyReturn->symbol."</td><td>".$buyReturn->quantity."</td></tr>");
+ }
+ else if ($isSell == TRUE)
+ {
+ $dateTime = new DateTime($sellEnhancedReturn->openDate);
+ print ("<tr><td>".$sellEnhancedReturn->orderID."</td><td>".$sellEnhancedReturn->orderStatus.
+ "</td><td>".$dateTime->format("m/d/Y h:i:s A")."</td><td>Pending".
+ "</td><td>$".$sellEnhancedReturn->orderFee."</td><td>".$sellEnhancedReturn->orderType.
+ "</td><td>".$sellEnhancedReturn->symbol."</td><td>".$sellEnhancedReturn->quantity."</td></tr>");
+ }
+ print ("</tbody></table>");
+ }
+
+ else if ($_POST['GETQUOTE'])
+ {
+ print("<div class=\"main-title\"><h1>Stock Quotes</h1>");
+ print("<script type=\"text/javascript\">var thisdate = new Date();
+ document.writeln(thisdate.toLocaleString());</script>");
+ print("</div>");
+ print("<table class=\"table-outer\" cellspacing=\"0\" align=\"center\"><thead>
+ <tr><th>Symbol</th><th>Company</th><th>Volume</th><th>Price Range</th>
+ <th>Open Price</th><th>Current Price</th><th>Gain(Loss)</th><th>Trade</th></tr></thead><tbody>");
+
+ if ($quotesReturn->symbol)
+ {
+ print ("<tr><td>".$quotesReturn->symbol."</td><td>".$quotesReturn->companyName.
+ "</td><td>".$quotesReturn->volume."</td><td>$".$quotesReturn->low."-$".
+ $quotesReturn->high."</td><td>$".$quotesReturn->open."</td>
+ <td>$".$quotesReturn->price."</td><td>");
+
+ if ($quotesReturn->change > 0)
+ {
+ print ("<span class=\"price-gain\">$".$quotesReturn->change."</span>");
+ }
+ else if ($quotesReturn->change < 0)
+ {
+ print ("<span class=\"price-loss\">$".$quotesReturn->change."</span>");
+ }
+ else
+ {
+ print ("<span>$".$quotesReturn->change."</span>");
+ }
+ print("</td><td><form action=\"confirmation.php\" method=\"post\">
+ <input type=\"hidden\" name=\"QUANTITY\" value=\"".$quotesReturn->volume."\">
+ <input type=\"hidden\" name=\"SYMBOL\" value=\"".$quotesReturn->symbol."\">
+ <input type=\"hidden\" name=\"PRICE\" value=\"".$quotesReturn->price."\">
+ <input type=\"submit\" name=\"BUY\" value=\"Buy\"></input></form></td></tr>");
+ }
+ print("</tbody></table>");
+ }
+ else if($quotesInitialPage == TRUE)
+ {
+ print("<div class=\"main-title\"><h1>Stock Quotes</h1>");
+ print("<script type=\"text/javascript\">var thisdate = new Date();
+ document.writeln(thisdate.toLocaleString());</script>");
+ print("</div>");
+ print("<table class=\"table-outer\" cellspacing=\"0\" align=\"center\"><thead>
+ <tr><th>Symbol</th><th>Company</th><th>Volume</th><th>Price Range</th>
+ <th>Open Price</th><th>Current Price</th><th>Gain(Loss)</th><th>Trade</th></tr></thead><tbody>");
+
+ $symbolCount = 0;
+ while($symbolCount < 5)
+ {
+ $quotes = GetQuote("s:".$symbolCount);
+
+ if ($quotes)
+ {
+ $quotesReturn = $quotes->getQuoteReturn;
+
+ if ($quotesReturn->symbol)
+ {
+ print ("<tr><td>".$quotesReturn->symbol."</td><td>".$quotesReturn->companyName.
+ "</td><td>".$quotesReturn->volume."</td><td>$".$quotesReturn->low."-$".
+ $quotesReturn->high."</td><td>$".$quotesReturn->open."</td>
+ <td>$".$quotesReturn->price."</td><td>");
+
+ if ($quotesReturn->change > 0)
+ {
+ print ("<span class=\"price-gain\">$".$quotesReturn->change."</span>");
+ }
+ else if ($quotesReturn->change < 0)
+ {
+ print ("<span class=\"price-loss\">$".$quotesReturn->change."</span>");
+ }
+ else
+ {
+ print ("<span>$".$quotesReturn->change."</span>");
+ }
+ print("</td><td><form action=\"confirmation.php\" method=\"post\">
+ <input type=\"hidden\" name=\"QUANTITY\" value=\"".$quotesReturn->volume."\">
+ <input type=\"hidden\" name=\"SYMBOL\" value=\"".$quotesReturn->symbol."\">
+ <input type=\"hidden\" name=\"PRICE\" value=\"".$quotesReturn->price."\">
+ <input type=\"submit\" name=\"BUY\" value=\"Buy\"></input></form></td></tr>");
+ }
+ }
+ $symbolCount ++;
+ }
+ print("</tbody></table>");
+
+ }
+
+ else
+ {
+ print("<div class=\"main-title\"><h1>Stock Quotes</h1>");
+ print("<script type=\"text/javascript\">var thisdate = new Date();
+ document.writeln(thisdate.toLocaleString());</script>");
+ print("</div>");
+ }
+
+ ?>
+
+ <div class="bottom">
+
+ <form method = "post" action = "quotes.php">
+ <input type="text" value="<?php print ($symbol); ?>" name="SYMBOLS" size="25"/>
+ <input type="submit" value="Get Quote" name="GETQUOTE" class="button"/>
+ </form>
+
+ </div>
+ </div>
+ <div id="footer">
+ <div style="float:left;">Copyright 2008, WSO2 Inc.</div>
+ <div style="margin-left:432px;float:left;">Powered by
+ <img align="top" src="images/powered-by-logo.gif" style="margin-top:-3px; margin-left: 0px;"/></div>
+ </div>
+ </div>
+ </body>
+
+</html>
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/register.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/register.php?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/register.php (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/register.php Wed Nov 26 02:49:04 2008
@@ -0,0 +1,187 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<?php
+require_once ("request_processor.php");
+
+if ($_POST['REGISTERUSER'])
+{
+ /*New user registration*/
+ $userID = $_POST['REQUESTEDID'];
+ $openBalance = $_POST['OPENBALANCE'];
+ $fullname = $_POST['FULLNAME'];
+ $email = $_POST['EMAIL'];
+ $address = $_POST['ADDRESS'];
+ $password = $_POST['PASSWORD'];
+ $creditcard = $_POST['CREDITCARD'];
+ $confpassword = $_POST['CONFIRMATIONPASSWORD'];
+
+ if ($userID == NULL || $password != $confpassword)
+ {
+ $invalidInformation = TRUE;
+ }
+ else
+ {
+ $response = RegisterUser($userID, $password, $fullname,
+ $address, $email, $creditcard, $openBalance);
+ if ($response)
+ {
+ $successfulRegistration = TRUE;
+ }
+ else
+ {
+ $invalidInformation = TRUE;
+ }
+ }
+}
+?>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+ <head>
+ <meta http-equiv="content-type" content="text/html;charset=utf-8" />
+ <meta name="generator" content="Adobe GoLive" />
+ <title>WSF/PHP StockTrader Welcome</title>
+ <link href="style.css" rel="stylesheet" type="text/css" media="all" />
+ </head>
+
+ <body>
+ <div id="content">
+ <div id="header">
+ <div class="logo"><img src="images/logo.gif"></div>
+ </div>
+ <div id="header-links">
+ <table>
+ <tr>
+ <td>
+ <a href="index.php">Welcome</a>
+ </td>
+ <td>
+ <a href="home.php">Home</a>
+ </td>
+ <td>
+ <a href="account.php">Account</a>
+ </td>
+ <td>
+ <a href="portfolio.php">Portfolio</a>
+ </td>
+ <td>
+ <a href="quotes.php">Quotes/Trade</a>
+ </td>
+ <td>
+ <a href="glossary.php">Glossary</a>
+ </td>
+ <td>
+ <a href="config.php">Config</a>
+ </td>
+ <td>
+ <a href="login.php">Login/Logout</a>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="middle">
+ <div class="main-title">
+ <h1>Register</h1>
+ <script type="text/javascript">
+ var thisdate = new Date();
+ document.writeln(thisdate.toLocaleString());
+ </script>
+ </div>
+
+ <?php
+ if ($successfulRegistration)
+ {
+ print("<p style=\"color: red\" align=\"center\">
+ Registration was successful, please <a href =\"login.php\">login</a>.</p>");
+ }
+
+ else
+ {
+ if ($invalidInformation)
+ {
+ print("<p style=\"color: red\" align=\"center\">Please enter valid information.</p>");
+ }
+ print ("<table class=\"profile\" cellspacing=\"0\" width=\"100%\">
+ <thead>
+ <tr>
+ <th>
+ Create Account Profile:
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>
+ <form action=\"register.php\" method=\"post\">
+ <table cellspacing=\"0\" align=\"center\">
+ <tr>
+ <td colspan=\"4\" >
+
+ </td>
+ </tr>
+ <tr>
+ <td>Requested ID:</td>
+ <td><input name=\"REQUESTEDID\" type=\"text\" id=\"\" size=\"25\"/></td>
+ <td>Opening Balance:</td>
+ <td><input type=\"text\" name=\"OPENBALANCE\" value=\"100000\" id=\"\" size=\"25\"/></td>
+ </tr>
+ <tr>
+ <td>Full Name:</td>
+ <td><input type=\"text\" name=\"FULLNAME\" id=\"\" size=\"25\"/></td>
+ <td>Email Address:</td>
+ <td><input type=\"text\" name=\"EMAIL\" id=\"\" size=\"25\"/></td>
+ </tr>
+ <tr>
+ <td>Address:</td>
+ <td><input name=\"ADDRESS\" type=\"text\" id=\"\" size=\"25\"/></td>
+ <td>Password:</td>
+ <td><input name=\"PASSWORD\" type=\"password\" id=\"\" size=\"25\"/></td>
+ </tr>
+ <tr>
+ <td>Credit Card:</td>
+ <td><input name=\"CREDITCARD\" type=\"text\" id=\"\" size=\"25\"/></td>
+ <td>Confirm Password:</td>
+ <td><input name=\"CONFIRMATIONPASSWORD\" type=\"password\" id=\"\" size=\"25\"/></td>
+ </tr>
+ <tr>
+ <td colspan=\"4\" class=\"button\">
+ <input type=\"submit\" name=\"REGISTERUSER\" value=\"Register\" class=\"button\"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </tbody>
+ </table>");
+ }
+ ?>
+ </div>
+ <div id="footer">
+ <div style="float:left;">Copyright 2008, WSO2 Inc.</div>
+ <div style="margin-left:432px;float:left;">Powered by
+ <img align="top" src="images/powered-by-logo.gif" style="margin-top:-3px; margin-left: 0px;"/></div>
+ </div>
+ </div>
+ </body>
+
+</html>
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor.php?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor.php (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor.php Wed Nov 26 02:49:04 2008
@@ -0,0 +1,1001 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define ("STATUS_SUCCESS", 1);
+define ("STATUS_FAILURE", 0);
+define ("TRUE", 1);
+define ("FALSE", 0);
+define ("ORDER_TYPE_BUY", "buy");
+define ("ORDER_TYPE_SELL", "sell");
+define ("COOKIE_USERNAME", "username");
+define ("COOKIE_ENDPOINT", "endpoint");
+define ("DEFAULT_ENDPOINT", "http://localhost:80/TradeServiceWcf/TradeServiceWcf.svc");
+define ("CLIENT_NAME", "PHP_CLIENT");
+
+/*this will set the default end point if end point is NOT already set.*/
+SetDefaultEndpoint();
+
+/**
+ * This class includes the summery of acctivities of the user
+ */
+
+class userAccountSummary
+{
+ public $totalBuys; //double
+ public $totalSells; //double
+ public $totalTax; //double
+ public $totalImpact; //double
+}
+
+/**
+ * This class encapsulates login data of a user
+ */
+
+class login
+{
+ public $userID; // string
+ public $password; // string
+}
+
+/**
+ * This class describes the response of login, if success gives
+ * the account details of the user
+ */
+
+class loginResponse
+{
+ public $loginReturn; // AccountDataBean
+}
+
+/**
+ * This class encapsulates user account details
+ */
+
+class AccountDataBean
+{
+ public $accountID; // int
+ public $loginCount; // int
+ public $logoutCount; // int
+ public $lastLogin; // dateTime
+ public $creationDate; // dateTime
+ public $balance; // decimal
+ public $openBalance; // decimal
+ public $profileID; // string
+}
+
+/**
+ * This class will contain details needed to get the orders of a user
+ */
+
+class getOrders
+{
+ public $userID; // string
+}
+
+/**
+ * This class encapsulates the response of a getOrders request
+ */
+
+class getOrdersResponse
+{
+ public $getOrdersReturn; // ArrayOfOrderDataBean
+}
+
+/**
+ * This class encapsulates the order details of a user
+ */
+
+class ArrayOfOrderDataBean
+{
+ public $OrderDataBean; // array[0, unbounded] of OrderDataBean
+}
+
+/**
+ * This class encapsulates the details of an order
+ */
+
+class OrderDataBean
+{
+ public $orderID; // int
+ public $orderType; // string
+ public $orderStatus; // string
+ public $openDate; // dateTime
+ public $completionDate; // dateTime
+ public $quantity; // double
+ public $price; // decimal
+ public $orderFee; // decimal
+ public $symbol; // string
+}
+
+/**
+ * This class encapsulates the details needed to get account data of a
+ * particular user
+ */
+
+class getAccountData
+{
+ public $userID; // string
+}
+
+/**
+ * This class encapsulates the response of getAccountData request
+ */
+
+class getAccountDataResponse
+{
+ public $getAccountDataReturn; // AccountDataBean
+}
+
+/**
+ * This class encapsulates details needed to get account profile information
+ */
+
+class getAccountProfileData
+{
+ public $userID; // string
+}
+
+/**
+ * This class encapsulates the response of getAccountProfileData request
+ */
+
+class getAccountProfileDataResponse
+{
+ public $getAccountProfileDataReturn; // AccountProfileDataBean
+}
+
+/**
+ * Encapsulates details of an account profile
+ */
+
+class AccountProfileDataBean
+{
+ public $userID; // string
+ public $password; // string
+ public $fullName; // string
+ public $address; // string
+ public $email; // string
+ public $creditCard; // string
+}
+
+/**
+ * Contain information needed to update account profile
+ */
+
+class updateAccountProfile
+{
+ public $profileData; // AccountProfileDataBean
+}
+
+/**
+ * Contains response of updated account profile
+ */
+
+class updateAccountProfileResponse {
+ public $updateAccountProfileReturn; // AccountProfileDataBean
+}
+
+/**
+ * Information needed to logout a user
+ */
+
+class logout
+{
+ public $userID; // string
+}
+
+/**
+ * Response of logout
+ */
+
+class logoutResponse
+{
+}
+
+/**
+ * Details needed to do "buy" transaction
+ */
+
+class buy
+{
+ public $userID; // string
+ public $symbol; // string
+ public $quantity; // double
+ public $orderProcessingMode; // int
+}
+
+/**
+ * Response of "buy" transaction
+ */
+
+class buyResponse
+{
+ public $buyReturn; // OrderDataBean
+}
+
+/**
+ * Details needed to do "sell" transaction
+ */
+
+class sell
+{
+ public $userID; // string
+ public $holdingID; // int
+ public $orderProcessingMode; // int
+}
+
+/**
+ * Response of "sell" transaction
+ */
+
+class sellResponse
+{
+ public $sellReturn; // OrderDataBean
+}
+
+/**
+ * Details needed to get holdings of a user
+ */
+
+class getHoldings
+{
+ public $userID; // string
+}
+
+/**
+ * Response of getHolding request
+ */
+
+class getHoldingsResponse
+{
+ public $getHoldingsReturn; // ArrayOfHoldingDataBean
+}
+
+/**
+ * Details of holdings of a user
+ */
+
+class ArrayOfHoldingDataBean
+{
+ public $HoldingDataBean; // array[0, unbounded] of HoldingDataBean
+}
+
+/**
+ * Details of a holding
+ */
+
+class HoldingDataBean
+{
+ public $holdingID; // int
+ public $quantity; // double
+ public $purchasePrice; // decimal
+ public $purchaseDate; // dateTime
+ public $quoteID; // string
+}
+
+/**
+ * Information needed to register a user to the system
+ */
+
+class register
+{
+ public $userID; // string
+ public $password; // string
+ public $fullname; // string
+ public $address; // string
+ public $email; // string
+ public $creditcard; // string
+ public $openBalance; // decimal
+}
+
+/**
+ * Account details of registered user
+ */
+
+class registerResponse
+{
+ public $registerReturn; // AccountDataBean
+}
+
+/**
+ * Details needed to get closed orders of a user
+ */
+
+class getClosedOrders
+{
+ public $userID; // string
+}
+
+/**
+ * Response of getClosedOrder request
+ */
+
+class getClosedOrdersResponse
+{
+ public $getClosedOrdersReturn; // ArrayOfOrderDataBean
+}
+
+/**
+ * Details needed to get market summery
+ */
+
+class getMarketSummary
+{
+}
+
+/**
+ * Response of getMarketSummary request
+ */
+
+class getMarketSummaryResponse
+{
+ public $getMarketSummaryReturn; // MarketSummaryDataBeanWS
+}
+
+/**
+ * Details about market summery
+ */
+
+class MarketSummaryDataBeanWS
+{
+ public $TSIA; // decimal
+ public $openTSIA; // decimal
+ public $volume; // double
+ public $topGainers; // ArrayOfQuoteDataBean
+ public $topLosers; // ArrayOfQuoteDataBean
+ public $summaryDate; // dateTime
+}
+
+/**
+ * Details of Quote request
+ */
+
+class ArrayOfQuoteDataBean
+{
+ public $QuoteDataBean; // array[0, unbounded] of QuoteDataBean
+}
+
+/**
+ * Details of a quote
+ */
+
+class QuoteDataBean
+{
+ public $symbol; // string
+ public $companyName; // string
+ public $price; // decimal
+ public $open; // decimal
+ public $low; // decimal
+ public $high; // decimal
+ public $change; // double
+ public $volume; // double
+}
+
+/**
+ * Details needed to get quote information of a symbol
+ */
+
+class getQuote
+{
+ public $symbol; // string
+}
+
+/**
+ * Response of getQuote request
+ */
+
+class getQuoteResponse
+{
+ public $getQuoteReturn; // QuoteDataBean
+}
+
+/**
+ * Details needed to get a particular holding of a user
+ */
+
+class getHolding
+{
+ public $userID; // string
+ public $holdingID; // int
+}
+
+/**
+ * Response of getHolding request
+ */
+
+class getHoldingResponse
+{
+ public $getHoldingReturn; // HoldingDataBean
+}
+
+/**
+ * Details needed to get top orders of a user
+ */
+
+class getTopOrders
+{
+ public $userID; // string
+}
+
+/**
+ * Response of getTopOrders request
+ */
+
+class getTopOrdersResponse
+{
+ public $getTopOrdersReturn; // ArrayOfOrderDataBean
+}
+
+/**
+ * Details needed to sell a holding of a user
+ */
+
+class sellEnhanced
+{
+ public $userID; // string
+ public $holdingID; // int
+ public $quantity; // double
+}
+
+/**
+ * Response of sellEnhanced request
+ */
+
+class sellEnhancedResponse
+{
+ public $sellEnhancedReturn; // OrderDataBean
+}
+
+/**
+ * Details needed to check whether service is online
+ */
+
+class isOnline
+{
+}
+
+/**
+ * Response of service's online status
+ */
+
+class isOnlineResponse
+{
+}
+
+/**
+ * Summery of holdings of a particular user
+ */
+
+class holdingInformation
+{
+ public $totalHoldings;
+ public $noOfHoldings;
+}
+
+/*
+ * Request send to get configurations parameter needed by client
+ */
+class ClientConfigRequest
+{
+ /**
+ * @var string
+ */
+ public $Client;
+}
+
+/*
+ * contains information needed by client
+ */
+class ClientConfigResponse
+{
+ /**
+ * @var anyURI
+ */
+ public $BS;
+}
+
+/*
+ * Get the endpoint of business service
+ */
+function GetBSEndPoint()
+{
+
+ // define the class map
+ $class_map = array(
+ "ClientConfigRequest" => "ClientConfigRequest",
+ "ClientConfigResponse" => "ClientConfigResponse");
+
+ // create client in WSDL mode
+ $client = new WSClient(array ("wsdl" =>"wsdl/config_svc.wsdl",
+ "classmap" => $class_map,
+ "to" => GetEndpoint()));
+
+ // get proxy object reference form client
+ $proxy = $client->getProxy();
+ $input = new ClientConfigRequest();
+ $input->Client = CLIENT_NAME;
+
+ $response = $proxy->ClientConfigRequest($input);
+ if($response)
+ {
+ $endPoint = $response->BS;
+ }
+
+ return $endPoint;
+}
+
+/**
+ * This method registes a new user in the system
+ * @param userID id of the user
+ * @param password password of the user
+ * @param fullname full name of the user
+ * @param address address of the user
+ * @param email email address of the user
+ * @param creditcard credit card number of the user
+ * @param openBalance initial balance of the user
+ * @return account details of the registerd user on success. NULL otherwise.
+ */
+
+function RegisterUser($userID, $password, $fullname,
+ $address, $email, $creditcard, $openBalance)
+{
+ $proxy = GetProxy();
+ $input = new register();
+ $input->userID = $userID;
+ $input->password = $password;
+ $input->fullname = $fullname;
+ $input->address = $address;
+ $input->email = $email;
+ $input->creditcard = $creditcard;
+ $input->openBalance = $openBalance;
+
+ $response = $proxy->register($input);
+ return $response;
+}
+
+/**
+ * Updates account profile information
+ * @param userID id of the user
+ * @param fullname full name of the user
+ * @param email email address of the user
+ * @param address address of the user
+ * @param creditcard credit card number of the user
+ * @param password password of the user
+ * @return account details of the modified user on success. NULL otherwise.
+ */
+
+function UpdateAccountProfile($userID, $fullName, $email,
+ $address, $creditCard, $password)
+{
+ $proxy = GetProxy();
+ $input = new updateAccountProfile();
+ $input->profileData = new AccountProfileDataBean();
+ $input->profileData->userID = $userID;
+ $input->profileData->password = $password;
+ $input->profileData->fullName = $fullName;
+ $input->profileData->address = $address;
+ $input->profileData->email = $email;
+ $input->profileData->creditCard = $creditCard;
+ $response = $proxy->updateAccountProfile($input);
+ return $response;
+}
+
+/**
+ * Given the order details of a user, this method calculates summery of
+ * activities of the user. This includes total money spent on buying stocks
+ * total money earned from selling them etc.
+ * @param ordersReturn collection of orders of a user
+ * @return summery of user's activities
+ */
+
+function GetUserAccountSummary($ordersReturn)
+{
+ $index = 0;
+ while($ordersReturn->OrderDataBean[$index])
+ {
+ if ($ordersReturn->OrderDataBean[$index]->orderType == ORDER_TYPE_BUY)
+ {
+ $buys = $buys + (($ordersReturn->OrderDataBean[$index]->price) *
+ ($ordersReturn->OrderDataBean[$index]->quantity)) +
+ ($ordersReturn->OrderDataBean[$index]->orderFee);
+ }
+ else if ($ordersReturn->OrderDataBean[$index]->orderType == ORDER_TYPE_SELL)
+ {
+ $sells = $sells + (($ordersReturn->OrderDataBean[$index]->price) *
+ ($ordersReturn->OrderDataBean[$index]->quantity)) -
+ ($ordersReturn->OrderDataBean[$index]->orderFee);
+ }
+ $tax = $tax + $ordersReturn->OrderDataBean[$index]->orderFee;
+ $index ++;
+ }
+ $accountSummary = new userAccountSummary();
+ $accountSummary->totalBuys = $buys;
+ $accountSummary->totalSells = $sells;
+ $accountSummary->totalTax = $tax;
+ $accountSummary->totalImpact = $buys + $tax - $sells;
+ return $accountSummary;
+}
+
+/**
+ * Given the holdings of a user, this methods calculate total market value of
+ * holding and number of holdings
+ * @param holdings collection of holdings of a user
+ * @return summery of holding details
+ */
+
+function GetHoldingInformation($holdings)
+{
+ $holdingsReturn = $holdings->getHoldingsReturn;
+ $index = 0;
+ $totalHoldings= 0;
+ $marketValue = 0;
+
+ while($holdingsReturn->HoldingDataBean[$index])
+ {
+ $bean = $holdingsReturn->HoldingDataBean[$index];
+ if (!$quoteInfo[$bean->quoteID])
+ {
+ $quotes = GetQuote($bean->quoteID);
+ if ($quotes)
+ $quotesReturn = $quotes->getQuoteReturn;
+ $quoteInfo[$bean->quoteID] = $quotesReturn->price;
+ }
+ $marketValue = $marketValue + ($quoteInfo[$bean->quoteID]) * ($bean->quantity);
+
+ $totalHoldings = $totalHoldings + $holdingsReturn->HoldingDataBean[$index]->quantity *
+ $holdingsReturn->HoldingDataBean[$index]->purchasePrice;
+ $index ++;
+ }
+ $holdingInfo = new holdingInformation();
+ $holdingInfo->totalHoldings = $marketValue;
+ $holdingInfo->noOfHoldings = $index;
+
+ return $holdingInfo;
+}
+
+/**
+ * Writes user id to cookie
+ * @param username user id of the current user
+ */
+
+function WriteCookie($username)
+{
+ setcookie(COOKIE_USERNAME, $username, time()+3600);
+}
+
+/**
+ * Deletes user id from cookie
+ * @param username user id of current user
+ */
+function DeleteCookie($username)
+{
+ setcookie(COOKIE_USERNAME, $username, time()-3600);
+ if (isset($_COOKIE[COOKIE_USERNAME]))
+ unset($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * When user logout, user id will be deleted from the cookie
+ * @param username user id of current user
+ */
+
+function LogoutUser($username)
+{
+ $proxy = GetProxy();
+ $input = new logout();
+ $input->userID = $username;
+ $response = $proxy->logout($input);
+ DeleteCookie($username);
+}
+
+/**
+ * Gets user id from cookie
+ */
+
+function GetUserFromCookie()
+{
+ return ($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * Checks whether user is logged in. If so, user id cookie would have
+ * been already set. Checking whether cookie is set equals to check
+ * whether user is logged in
+ */
+
+function IsLoggedIn()
+{
+ return isset($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * Gets user id of current user
+ */
+
+function GetUser()
+{
+ return ($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * Store business service's endpoint in cookie
+ * @param endPoint end point address of the business service
+ */
+
+function WriteEndpoint($endPoint)
+{
+ setcookie(COOKIE_ENDPOINT, $endPoint, time()+3600);
+}
+
+/**
+ * Sets default end point
+ */
+
+function SetDefaultEndpoint()
+{
+ if(GetEndpoint() == "")
+ WriteEndpoint(DEFAULT_ENDPOINT);
+}
+
+/**
+ * Gets stored end point address of business service
+ */
+
+function GetEndpoint()
+{
+ return ($_COOKIE[COOKIE_ENDPOINT]);
+}
+
+/**
+ * Gets proxy object to make communication with business service
+ */
+
+function GetProxy()
+{
+ /*define the class map */
+
+ $class_map = array(
+ "anyType" => "anyType", "login" => "login",
+ "loginResponse" => "loginResponse", "AccountDataBean" =>
+ "AccountDataBean", "getOrders" => "getOrders", "getOrdersResponse" =>
+ "getOrdersResponse", "ArrayOfOrderDataBean" => "ArrayOfOrderDataBean",
+ "OrderDataBean" => "OrderDataBean", "getAccountData" => "getAccountData",
+ "getAccountDataResponse" => "getAccountDataResponse",
+ "getAccountProfileData" => "getAccountProfileData",
+ "getAccountProfileDataResponse" => "getAccountProfileDataResponse",
+ "AccountProfileDataBean" => "AccountProfileDataBean",
+ "updateAccountProfile" => "updateAccountProfile",
+ "updateAccountProfileResponse" => "updateAccountProfileResponse",
+ "logout" => "logout", "logoutResponse" => "logoutResponse", "buy"
+ => "buy", "buyResponse" => "buyResponse", "sell" => "sell",
+ "sellResponse" => "sellResponse", "getHoldings" => "getHoldings",
+ "getHoldingsResponse" => "getHoldingsResponse", "ArrayOfHoldingDataBean"
+ => "ArrayOfHoldingDataBean", "HoldingDataBean" => "HoldingDataBean",
+ "register" => "register", "registerResponse" => "registerResponse",
+ "getClosedOrders" => "getClosedOrders", "getClosedOrdersResponse" =>
+ "getClosedOrdersResponse", "getMarketSummary" => "getMarketSummary",
+ "getMarketSummaryResponse" => "getMarketSummaryResponse",
+ "MarketSummaryDataBeanWS" => "MarketSummaryDataBeanWS",
+ "ArrayOfQuoteDataBean" => "ArrayOfQuoteDataBean", "QuoteDataBean" =>
+ "QuoteDataBean", "getQuote" => "getQuote", "getQuoteResponse" =>
+ "getQuoteResponse", "getHolding" => "getHolding", "getHoldingResponse"
+ => "getHoldingResponse", "getTopOrders" => "getTopOrders",
+ "getTopOrdersResponse" => "getTopOrdersResponse", "sellEnhanced" =>
+ "sellEnhanced", "sellEnhancedResponse" => "sellEnhancedResponse",
+ "isOnline" => "isOnline", "isOnlineResponse" => "isOnlineResponse");
+
+ $client = new WSClient(array ("wsdl" =>"wsdl/TradeServiceWcf.svc.wsdl",
+ "classmap" => $class_map,
+ "to" => GetBSEndPoint()));
+ //We can set this port through tcpmon
+
+ $proxy = $client->getProxy();
+ return $proxy;
+}
+
+/**
+ * Sends login request to verify whether current user is authorized
+ * @param userid user id of current user
+ * @param password password given by current user
+ * @return profile id of the user if login is success. NULL otherwise
+ */
+
+function Login($userid, $password)
+{
+ $proxy = GetProxy();
+ $input = new login();
+ $input->userID = $userid;
+ $input->password = $password;
+ $response = $proxy->login($input);
+
+ return $response->loginReturn->profileID;
+}
+
+/**
+ * Gets orders of current user
+ * @param userid user id of current user
+ * @return collection of orders of the user
+ */
+
+function GetOrders($userid)
+{
+ $proxy = GetProxy();
+ $input = new getOrders();
+ $input->userID = $userid;
+ $response = $proxy->getOrders($input);
+ return $response;
+}
+
+/**
+ * Gets market summary
+ * @return market summery
+ */
+
+function GetMarketSummary()
+{
+ $proxy = GetProxy();
+ $input = new getMarketSummary();
+ $response = $proxy->getMarketSummary($input);
+ return $response;
+}
+
+/**
+ * Gets account details of current user
+ * @param userid user id of current user
+ * @return account details if success. NULL otherwise
+ */
+
+function GetAccountData($userid)
+{
+ $proxy = GetProxy();
+ $input = new getAccountData();
+ $input->userID = $userid;
+ $response = $proxy->getAccountData($input);
+ return $response;
+}
+
+/**
+ * Gets account profile information of current user
+ * @param userid user id of current user
+ * @return account profile data of current user if success. NULL otherwise
+ */
+
+function GetAccountProfileData($userid)
+{
+ $proxy = GetProxy();
+ $input = new getAccountProfileData();
+ $input->userID = $userid;
+ $response = $proxy->getAccountProfileData($input);
+ return $response;
+}
+
+/**
+ * Gets holding details of given user
+ * @param userid user id of current user
+ * returns collection of holding if success. NULL otherwise
+ */
+
+function GetHoldings($userid)
+{
+ $proxy = GetProxy();
+ $input = new getHoldings();
+ $input->userID = $userid;
+ $response = $proxy->getHoldings($input);
+ return $response;
+}
+
+/**
+ * Gets quote of given symbol
+ * @param symbol id of the stock
+ * @return details of the symbol when success. NULL otherwise
+ */
+
+function GetQuote($symbol)
+{
+ $proxy = GetProxy();
+ $input = new getQuote();
+ $input->symbol = $symbol;
+ $response = $proxy->getQuote($input);
+ return $response;
+}
+
+
+/**
+ * Sells given holding or part of it of given user
+ * @param userID user id of current user
+ * @param holdingID holding id of the holding
+ * @param quantity number of stocks to be sold
+ * @return details of sell order if success. NULL otherwise
+ */
+
+function SellEnhanced($userID, $holdingID, $quantity)
+{
+ $proxy = GetProxy();
+ $input = new sellEnhanced();
+ $input->userID = $userID;
+ $input->holdingID = $holdingID;
+ $input->quantity = $quantity;
+ $response = $proxy->sellEnhanced($input);
+ return $response;
+}
+
+/**
+ * Buys number of stocks of given symbol
+ * @param userID user id of current user
+ * @param symbol symbol of needed stock
+ * @quantity number of stocks needed
+ * @mode mode of buying
+ * @return details of buy order if success. NULL otherwise
+ */
+
+function Buy($userID, $symbol, $quantity, $mode)
+{
+ $proxy = GetProxy();
+ $input = new buy();
+ $input->symbol = $symbol;
+ $input->userID = $userID;
+ $input->quantity = $quantity;
+ $input->orderProcessingMode = $mode;
+ $response = $proxy->buy($input);
+ return $response;
+}
+
+/**
+ * Gets closed orders of current user
+ * @return collection of orders whose status is closed
+ */
+
+function GetClosedOrders()
+{
+ $proxy = GetProxy();
+ $input = new getClosedOrders();
+ $input->userID = GetUserFromCookie();
+ if($input->userID)
+ {
+ $response = $proxy->getClosedOrders($input);
+ $getClosedOrdersReturn = $response->getClosedOrdersReturn;
+ }
+ return $getClosedOrdersReturn;
+}
+
+/**
+ * Gets closed orders of current user if there are any. Then prints it
+ */
+
+function checkForClosedOrders()
+{
+ $proxy = GetProxy();
+ $input = new getClosedOrders();
+ $input->userID = GetUserFromCookie();
+ if($input->userID)
+ {
+ $response = $proxy->getClosedOrders($input);
+ $getClosedOrdersReturn = $response->getClosedOrdersReturn;
+
+ $index = 0;
+ while ($getClosedOrdersReturn->OrderDataBean[$index])
+ {
+ print("THIS IS THE ID OF THE JUST CLOSED ORDER:");
+ print($getClosedOrdersReturn->OrderDataBean[$index]->orderID);
+ print("\n");
+ $index ++;
+ }
+ }
+}
+
+?>
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor_msec.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor_msec.php?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor_msec.php (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/request_processor_msec.php Wed Nov 26 02:49:04 2008
@@ -0,0 +1,945 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+define ("STATUS_SUCCESS", 1);
+define ("STATUS_FAILURE", 0);
+define ("TRUE", 1);
+define ("FALSE", 0);
+define ("ORDER_TYPE_BUY", "buy");
+define ("ORDER_TYPE_SELL", "sell");
+define ("COOKIE_USERNAME", "username");
+define ("COOKIE_ENDPOINT", "endpoint");
+define ("DEFAULT_ENDPOINT", "http://localhost:80/TradeServiceWcf/TradeServiceWcf.svc");
+
+/*this will set the default end point if end point is NOT already set.*/
+SetDefaultEndpoint();
+
+/**
+ * This class includes the summery of acctivities of the user
+ */
+
+class userAccountSummary
+{
+ public $totalBuys; //double
+ public $totalSells; //double
+ public $totalTax; //double
+ public $totalImpact; //double
+}
+
+/**
+ * This class encapsulates login data of a user
+ */
+
+class login
+{
+ public $userID; // string
+ public $password; // string
+}
+
+/**
+ * This class describes the response of login, if success gives
+ * the account details of the user
+ */
+
+class loginResponse
+{
+ public $loginReturn; // AccountDataBean
+}
+
+/**
+ * This class encapsulates user account details
+ */
+
+class AccountDataBean
+{
+ public $accountID; // int
+ public $loginCount; // int
+ public $logoutCount; // int
+ public $lastLogin; // dateTime
+ public $creationDate; // dateTime
+ public $balance; // decimal
+ public $openBalance; // decimal
+ public $profileID; // string
+}
+
+/**
+ * This class will contain details needed to get the orders of a user
+ */
+
+class getOrders
+{
+ public $userID; // string
+}
+
+/**
+ * This class encapsulates the response of a getOrders request
+ */
+
+class getOrdersResponse
+{
+ public $getOrdersReturn; // ArrayOfOrderDataBean
+}
+
+/**
+ * This class encapsulates the order details of a user
+ */
+
+class ArrayOfOrderDataBean
+{
+ public $OrderDataBean; // array[0, unbounded] of OrderDataBean
+}
+
+/**
+ * This class encapsulates the details of an order
+ */
+
+class OrderDataBean
+{
+ public $orderID; // int
+ public $orderType; // string
+ public $orderStatus; // string
+ public $openDate; // dateTime
+ public $completionDate; // dateTime
+ public $quantity; // double
+ public $price; // decimal
+ public $orderFee; // decimal
+ public $symbol; // string
+}
+
+/**
+ * This class encapsulates the details needed to get account data of a
+ * particular user
+ */
+
+class getAccountData
+{
+ public $userID; // string
+}
+
+/**
+ * This class encapsulates the response of getAccountData request
+ */
+
+class getAccountDataResponse
+{
+ public $getAccountDataReturn; // AccountDataBean
+}
+
+/**
+ * This class encapsulates details needed to get account profile information
+ */
+
+class getAccountProfileData
+{
+ public $userID; // string
+}
+
+/**
+ * This class encapsulates the response of getAccountProfileData request
+ */
+
+class getAccountProfileDataResponse
+{
+ public $getAccountProfileDataReturn; // AccountProfileDataBean
+}
+
+/**
+ * Encapsulates details of an account profile
+ */
+
+class AccountProfileDataBean
+{
+ public $userID; // string
+ public $password; // string
+ public $fullName; // string
+ public $address; // string
+ public $email; // string
+ public $creditCard; // string
+}
+
+/**
+ * Contain information needed to update account profile
+ */
+
+class updateAccountProfile
+{
+ public $AccountProfileDataModel; // AccountProfileDataBean
+}
+
+/**
+ * Contains response of updated account profile
+ */
+
+class updateAccountProfileResponse {
+ public $updateAccountProfileReturn; // AccountProfileDataBean
+}
+
+/**
+ * Information needed to logout a user
+ */
+
+class logout
+{
+ public $userID; // string
+}
+
+/**
+ * Response of logout
+ */
+
+class logoutResponse
+{
+}
+
+/**
+ * Details needed to do "buy" transaction
+ */
+
+class buy
+{
+ public $userID; // string
+ public $symbol; // string
+ public $quantity; // double
+ public $orderProcessingMode; // int
+}
+
+/**
+ * Response of "buy" transaction
+ */
+
+class buyResponse
+{
+ public $buyReturn; // OrderDataBean
+}
+
+/**
+ * Details needed to do "sell" transaction
+ */
+
+class sell
+{
+ public $userID; // string
+ public $holdingID; // int
+ public $orderProcessingMode; // int
+}
+
+/**
+ * Response of "sell" transaction
+ */
+
+class sellResponse
+{
+ public $sellReturn; // OrderDataBean
+}
+
+/**
+ * Details needed to get holdings of a user
+ */
+
+class getHoldings
+{
+ public $userID; // string
+}
+
+/**
+ * Response of getHolding request
+ */
+
+class getHoldingsResponse
+{
+ public $getHoldingsReturn; // ArrayOfHoldingDataBean
+}
+
+/**
+ * Details of holdings of a user
+ */
+
+class ArrayOfHoldingDataBean
+{
+ public $HoldingDataBean; // array[0, unbounded] of HoldingDataBean
+}
+
+/**
+ * Details of a holding
+ */
+
+class HoldingDataBean
+{
+ public $holdingID; // int
+ public $quantity; // double
+ public $purchasePrice; // decimal
+ public $purchaseDate; // dateTime
+ public $quoteID; // string
+}
+
+/**
+ * Information needed to register a user to the system
+ */
+
+class register
+{
+ public $userID; // string
+ public $password; // string
+ public $fullname; // string
+ public $address; // string
+ public $email; // string
+ public $creditcard; // string
+ public $openBalance; // decimal
+}
+
+/**
+ * Account details of registered user
+ */
+
+class registerResponse
+{
+ public $registerReturn; // AccountDataBean
+}
+
+/**
+ * Details needed to get closed orders of a user
+ */
+
+class getClosedOrders
+{
+ public $userID; // string
+}
+
+/**
+ * Response of getClosedOrder request
+ */
+
+class getClosedOrdersResponse
+{
+ public $getClosedOrdersReturn; // ArrayOfOrderDataBean
+}
+
+/**
+ * Details needed to get market summery
+ */
+
+class getMarketSummary
+{
+}
+
+/**
+ * Response of getMarketSummary request
+ */
+
+class getMarketSummaryResponse
+{
+ public $getMarketSummaryReturn; // MarketSummaryDataBeanWS
+}
+
+/**
+ * Details about market summery
+ */
+
+class MarketSummaryDataBeanWS
+{
+ public $TSIA; // decimal
+ public $openTSIA; // decimal
+ public $volume; // double
+ public $topGainers; // ArrayOfQuoteDataBean
+ public $topLosers; // ArrayOfQuoteDataBean
+ public $summaryDate; // dateTime
+}
+
+/**
+ * Details of Quote request
+ */
+
+class ArrayOfQuoteDataBean
+{
+ public $QuoteDataBean; // array[0, unbounded] of QuoteDataBean
+}
+
+/**
+ * Details of a quote
+ */
+
+class QuoteDataBean
+{
+ public $symbol; // string
+ public $companyName; // string
+ public $price; // decimal
+ public $open; // decimal
+ public $low; // decimal
+ public $high; // decimal
+ public $change; // double
+ public $volume; // double
+}
+
+/**
+ * Details needed to get quote information of a symbol
+ */
+
+class getQuote
+{
+ public $symbol; // string
+}
+
+/**
+ * Response of getQuote request
+ */
+
+class getQuoteResponse
+{
+ public $getQuoteReturn; // QuoteDataBean
+}
+
+/**
+ * Details needed to get a particular holding of a user
+ */
+
+class getHolding
+{
+ public $userID; // string
+ public $holdingID; // int
+}
+
+/**
+ * Response of getHolding request
+ */
+
+class getHoldingResponse
+{
+ public $getHoldingReturn; // HoldingDataBean
+}
+
+/**
+ * Details needed to get top orders of a user
+ */
+
+class getTopOrders
+{
+ public $userID; // string
+}
+
+/**
+ * Response of getTopOrders request
+ */
+
+class getTopOrdersResponse
+{
+ public $getTopOrdersReturn; // ArrayOfOrderDataBean
+}
+
+/**
+ * Details needed to sell a holding of a user
+ */
+
+class sellEnhanced
+{
+ public $userID; // string
+ public $holdingID; // int
+ public $quantity; // double
+}
+
+/**
+ * Response of sellEnhanced request
+ */
+
+class sellEnhancedResponse
+{
+ public $sellEnhancedReturn; // OrderDataBean
+}
+
+/**
+ * Details needed to check whether service is online
+ */
+
+class isOnline
+{
+}
+
+/**
+ * Response of service's online status
+ */
+
+class isOnlineResponse
+{
+}
+
+/**
+ * Summery of holdings of a particular user
+ */
+
+class holdingInformation
+{
+ public $totalHoldings;
+ public $noOfHoldings;
+}
+
+/**
+ * This method registes a new user in the system
+ * @param userID id of the user
+ * @param password password of the user
+ * @param fullname full name of the user
+ * @param address address of the user
+ * @param email email address of the user
+ * @param creditcard credit card number of the user
+ * @param openBalance initial balance of the user
+ * @return account details of the registerd user on success. NULL otherwise.
+ */
+
+function RegisterUser($userID, $password, $fullname,
+ $address, $email, $creditcard, $openBalance)
+{
+ $proxy = GetProxy();
+ $input = new register();
+ $input->userID = $userID;
+ $input->password = $password;
+ $input->fullname = $fullname;
+ $input->address = $address;
+ $input->email = $email;
+ $input->creditcard = $creditcard;
+ $input->openBalance = $openBalance;
+
+ $response = $proxy->register($input);
+ return $response;
+}
+
+/**
+ * Updates account profile information
+ * @param userID id of the user
+ * @param fullname full name of the user
+ * @param email email address of the user
+ * @param address address of the user
+ * @param creditcard credit card number of the user
+ * @param password password of the user
+ * @return account details of the modified user on success. NULL otherwise.
+ */
+
+function UpdateAccountProfile($userID, $fullName, $email,
+ $address, $creditCard, $password)
+{
+ $proxy = GetProxy();
+ $input = new updateAccountProfile();
+ $input->AccountProfileDataModel = new AccountProfileDataBean();
+ $input->AccountProfileDataModel->userID = $userID;
+ $input->AccountProfileDataModel->password = $password;
+ $input->AccountProfileDataModel->fullName = $fullName;
+ $input->AccountProfileDataModel->address = $address;
+ $input->AccountProfileDataModel->email = $email;
+ $input->AccountProfileDataModel->creditCard = $creditCard;
+ $response = $proxy->updateAccountProfile($input);
+ return $response;
+}
+
+/**
+ * Given the order details of a user, this method calculates summery of
+ * activities of the user. This includes total money spent on buying stocks
+ * total money earned from selling them etc.
+ * @param ordersReturn collection of orders of a user
+ * @return summery of user's activities
+ */
+
+function GetUserAccountSummary($ordersReturn)
+{
+ $index = 0;
+ while($ordersReturn->OrderDataBean[$index])
+ {
+ if ($ordersReturn->OrderDataBean[$index]->orderType == ORDER_TYPE_BUY)
+ {
+ $buys = $buys + (($ordersReturn->OrderDataBean[$index]->price) *
+ ($ordersReturn->OrderDataBean[$index]->quantity)) +
+ ($ordersReturn->OrderDataBean[$index]->orderFee);
+ }
+ else if ($ordersReturn->OrderDataBean[$index]->orderType == ORDER_TYPE_SELL)
+ {
+ $sells = $sells + (($ordersReturn->OrderDataBean[$index]->price) *
+ ($ordersReturn->OrderDataBean[$index]->quantity)) -
+ ($ordersReturn->OrderDataBean[$index]->orderFee);
+ }
+ $tax = $tax + $ordersReturn->OrderDataBean[$index]->orderFee;
+ $index ++;
+ }
+ $accountSummary = new userAccountSummary();
+ $accountSummary->totalBuys = $buys;
+ $accountSummary->totalSells = $sells;
+ $accountSummary->totalTax = $tax;
+ $accountSummary->totalImpact = $buys + $tax - $sells;
+ return $accountSummary;
+}
+
+/**
+ * Given the holdings of a user, this methods calculate total market value of
+ * holding and number of holdings
+ * @param holdings collection of holdings of a user
+ * @return summery of holding details
+ */
+
+function GetHoldingInformation($holdings)
+{
+ $holdingsReturn = $holdings->getHoldingsReturn;
+ $index = 0;
+ $totalHoldings= 0;
+ $marketValue = 0;
+
+ while($holdingsReturn->HoldingDataBean[$index])
+ {
+ $bean = $holdingsReturn->HoldingDataBean[$index];
+ if (!$quoteInfo[$bean->quoteID])
+ {
+ $quotes = GetQuote($bean->quoteID);
+ if ($quotes)
+ $quotesReturn = $quotes->getQuoteReturn;
+ $quoteInfo[$bean->quoteID] = $quotesReturn->price;
+ }
+ $marketValue = $marketValue + ($quoteInfo[$bean->quoteID]) * ($bean->quantity);
+
+ $totalHoldings = $totalHoldings + $holdingsReturn->HoldingDataBean[$index]->quantity *
+ $holdingsReturn->HoldingDataBean[$index]->purchasePrice;
+ $index ++;
+ }
+ $holdingInfo = new holdingInformation();
+ $holdingInfo->totalHoldings = $marketValue;
+ $holdingInfo->noOfHoldings = $index;
+
+ return $holdingInfo;
+}
+
+/**
+ * Writes user id to cookie
+ * @param username user id of the current user
+ */
+
+function WriteCookie($username)
+{
+ setcookie(COOKIE_USERNAME, $username, time()+3600);
+}
+
+/**
+ * Deletes user id from cookie
+ * @param username user id of current user
+ */
+function DeleteCookie($username)
+{
+ setcookie(COOKIE_USERNAME, $username, time()-3600);
+ if (isset($_COOKIE[COOKIE_USERNAME]))
+ unset($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * When user logout, user id will be deleted from the cookie
+ * @param username user id of current user
+ */
+
+function LogoutUser($username)
+{
+ DeleteCookie($username);
+}
+
+/**
+ * Gets user id from cookie
+ */
+
+function GetUserFromCookie()
+{
+ return ($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * Checks whether user is logged in. If so, user id cookie would have
+ * been already set. Checking whether cookie is set equals to check
+ * whether user is logged in
+ */
+
+function IsLoggedIn()
+{
+ return isset($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * Gets user id of current user
+ */
+
+function GetUser()
+{
+ return ($_COOKIE[COOKIE_USERNAME]);
+}
+
+/**
+ * Store business service's endpoint in cookie
+ * @param endPoint end point address of the business service
+ */
+
+function WriteEndpoint($endPoint)
+{
+ setcookie(COOKIE_ENDPOINT, $endPoint, time()+3600);
+}
+
+/**
+ * Sets default end point
+ */
+
+function SetDefaultEndpoint()
+{
+ if(GetEndpoint() == "")
+ WriteEndpoint(DEFAULT_ENDPOINT);
+}
+
+/**
+ * Gets stored end point address of business service
+ */
+
+function GetEndpoint()
+{
+ return ($_COOKIE[COOKIE_ENDPOINT]);
+}
+
+/**
+ * Gets proxy object to make communication with business service
+ */
+
+function GetProxy()
+{
+ /*define the class map */
+
+ $class_map = array(
+ "anyType" => "anyType", "login" => "login",
+ "loginResponse" => "loginResponse", "AccountDataBean" =>
+ "AccountDataBean", "getOrders" => "getOrders", "getOrdersResponse" =>
+ "getOrdersResponse", "ArrayOfOrderDataBean" => "ArrayOfOrderDataBean",
+ "OrderDataBean" => "OrderDataBean", "getAccountData" => "getAccountData",
+ "getAccountDataResponse" => "getAccountDataResponse",
+ "getAccountProfileData" => "getAccountProfileData",
+ "getAccountProfileDataResponse" => "getAccountProfileDataResponse",
+ "AccountProfileDataBean" => "AccountProfileDataBean",
+ "updateAccountProfile" => "updateAccountProfile",
+ "updateAccountProfileResponse" => "updateAccountProfileResponse",
+ "logout" => "logout", "logoutResponse" => "logoutResponse", "buy"
+ => "buy", "buyResponse" => "buyResponse", "sell" => "sell",
+ "sellResponse" => "sellResponse", "getHoldings" => "getHoldings",
+ "getHoldingsResponse" => "getHoldingsResponse", "ArrayOfHoldingDataBean"
+ => "ArrayOfHoldingDataBean", "HoldingDataBean" => "HoldingDataBean",
+ "register" => "register", "registerResponse" => "registerResponse",
+ "getClosedOrders" => "getClosedOrders", "getClosedOrdersResponse" =>
+ "getClosedOrdersResponse", "getMarketSummary" => "getMarketSummary",
+ "getMarketSummaryResponse" => "getMarketSummaryResponse",
+ "MarketSummaryDataBeanWS" => "MarketSummaryDataBeanWS",
+ "ArrayOfQuoteDataBean" => "ArrayOfQuoteDataBean", "QuoteDataBean" =>
+ "QuoteDataBean", "getQuote" => "getQuote", "getQuoteResponse" =>
+ "getQuoteResponse", "getHolding" => "getHolding", "getHoldingResponse"
+ => "getHoldingResponse", "getTopOrders" => "getTopOrders",
+ "getTopOrdersResponse" => "getTopOrdersResponse", "sellEnhanced" =>
+ "sellEnhanced", "sellEnhancedResponse" => "sellEnhancedResponse",
+ "isOnline" => "isOnline", "isOnlineResponse" => "isOnlineResponse");
+
+ $client = new WSClient(array ("wsdl" =>"wsdl/TradeServiceWcf.svc.wsdl",
+ "classmap" => $class_map,
+ "to" => (GetEndpoint())));
+ //We can set this port through tcpmon
+
+ $proxy = $client->getProxy();
+ return $proxy;
+}
+
+/**
+ * Sends login request to verify whether current user is authorized
+ * @param userid user id of current user
+ * @param password password given by current user
+ * @return profile id of the user if login is success. NULL otherwise
+ */
+
+function Login($userid, $password)
+{
+ $proxy = GetProxy();
+ $input = new login();
+ $input->userID = $userid;
+ $input->password = $password;
+ $response = $proxy->login($input);
+
+ return $response->loginReturn->profileID;
+}
+
+/**
+ * Gets orders of current user
+ * @param userid user id of current user
+ * @return collection of orders of the user
+ */
+
+function GetOrders($userid)
+{
+ $proxy = GetProxy();
+ $input = new getOrders();
+ $input->userID = $userid;
+ $response = $proxy->getOrders($input);
+ return $response;
+}
+
+/**
+ * Gets market summary
+ * @return market summery
+ */
+
+function GetMarketSummary()
+{
+ $proxy = GetProxy();
+ $input = new getMarketSummary();
+ $response = $proxy->getMarketSummary($input);
+ return $response;
+}
+
+/**
+ * Gets account details of current user
+ * @param userid user id of current user
+ * @return account details if success. NULL otherwise
+ */
+
+function GetAccountData($userid)
+{
+ $proxy = GetProxy();
+ $input = new getAccountData();
+ $input->userID = $userid;
+ $response = $proxy->getAccountData($input);
+ return $response;
+}
+
+/**
+ * Gets account profile information of current user
+ * @param userid user id of current user
+ * @return account profile data of current user if success. NULL otherwise
+ */
+
+function GetAccountProfileData($userid)
+{
+ $proxy = GetProxy();
+ $input = new getAccountProfileData();
+ $input->userID = $userid;
+ $response = $proxy->getAccountProfileData($input);
+ return $response;
+}
+
+/**
+ * Gets holding details of given user
+ * @param userid user id of current user
+ * returns collection of holding if success. NULL otherwise
+ */
+
+function GetHoldings($userid)
+{
+ $proxy = GetProxy();
+ $input = new getHoldings();
+ $input->userID = $userid;
+ $response = $proxy->getHoldings($input);
+ return $response;
+}
+
+/**
+ * Gets quote of given symbol
+ * @param symbol id of the stock
+ * @return details of the symbol when success. NULL otherwise
+ */
+
+function GetQuote($symbol)
+{
+ $proxy = GetProxy();
+ $input = new getQuote();
+ $input->symbol = $symbol;
+ $response = $proxy->getQuote($input);
+ return $response;
+}
+
+
+/**
+ * Sells given holding or part of it of given user
+ * @param userID user id of current user
+ * @param holdingID holding id of the holding
+ * @param quantity number of stocks to be sold
+ * @return details of sell order if success. NULL otherwise
+ */
+
+function SellEnhanced($userID, $holdingID, $quantity)
+{
+ $proxy = GetProxy();
+ $input = new sellEnhanced();
+ $input->userID = $userID;
+ $input->holdingID = $holdingID;
+ $input->quantity = $quantity;
+ $response = $proxy->sellEnhanced($input);
+ return $response;
+}
+
+/**
+ * Buys number of stocks of given symbol
+ * @param userID user id of current user
+ * @param symbol symbol of needed stock
+ * @quantity number of stocks needed
+ * @mode mode of buying
+ * @return details of buy order if success. NULL otherwise
+ */
+
+function Buy($userID, $symbol, $quantity, $mode)
+{
+ $proxy = GetProxy();
+ $input = new buy();
+ $input->symbol = $symbol;
+ $input->userID = $userID;
+ $input->quantity = $quantity;
+ $input->orderProcessingMode = $mode;
+ $response = $proxy->buy($input);
+ return $response;
+}
+
+/**
+ * Gets closed orders of current user
+ * @return collection of orders whose status is closed
+ */
+
+function GetClosedOrders()
+{
+ $proxy = GetProxy();
+ $input = new getClosedOrders();
+ $input->userID = GetUserFromCookie();
+ if($input->userID)
+ {
+ $response = $proxy->getClosedOrders($input);
+ $getClosedOrdersReturn = $response->getClosedOrdersReturn;
+ }
+ return $getClosedOrdersReturn;
+}
+
+/**
+ * Gets closed orders of current user if there are any. Then prints it
+ */
+
+function checkForClosedOrders()
+{
+ $proxy = GetProxy();
+ $input = new getClosedOrders();
+ $input->userID = GetUserFromCookie();
+ if($input->userID)
+ {
+ $response = $proxy->getClosedOrders($input);
+ $getClosedOrdersReturn = $response->getClosedOrdersReturn;
+
+ $index = 0;
+ while ($getClosedOrdersReturn->OrderDataBean[$index])
+ {
+ print("THIS IS THE ID OF THE JUST CLOSED ORDER:");
+ print($getClosedOrdersReturn->OrderDataBean[$index]->orderID);
+ print("\n");
+ $index ++;
+ }
+ }
+}
+
+?>
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/style.css
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/style.css?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/style.css (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/style.css Wed Nov 26 02:49:04 2008
@@ -0,0 +1,373 @@
+body {
+background-image: url(images/bg.gif);
+background-repeat: repeat-x;
+background-position: left top;
+background-attachment: scroll;
+font-size: 11px;
+font-family: Verdana, Arial, Helvetica, san-serif;
+padding: 0px;
+margin: 0px;
+}
+
+p { }
+
+h3 {
+margin-top:5px;
+font-size: 16px;
+font-weight: normal;
+color: #F47B20;
+}
+
+td { }
+
+a:link {
+color: #0054A6;
+text-decoration: none;
+}
+
+a:visited {
+
+}
+
+a:hover {
+text-decoration: underline;
+}
+
+a:active { }
+
+input {
+border-left: solid 1px #999;
+border-bottom: solid 1px #333;
+border-right: solid 1px #333;
+border-top: solid 1px #999;
+margin-right: 7px;
+}
+input.button {
+background-image: url(images/button-bg.gif);
+background-repeat: repeat-x;
+background-position: left top;
+background-attachment: scroll;
+border-left: solid 1px #FDBB30;
+border-bottom: solid 2px #F47B20;
+border-right: solid 2px #F47B20;
+border-top: solid 1px #FDBB30;
+height: 22px;
+font-weight: bold;
+padding-left: 10px;
+padding-right: 10px;
+cursor: pointer;
+}
+td {
+vertical-align: top;
+}
+
+div#content {
+width: 902px;
+margin: auto;
+margin-top: 15px;
+}
+div#header {
+background-image: url(images/header-bg.gif);
+background-repeat: no-repeat;
+background-position: left top;
+background-attachment: scroll;
+background-color: #fff;
+height: 57px;
+}
+div#header div.logo {
+float: left;
+margin-top: 0px;
+margin-left: 20px;
+}
+div#header div.powered {
+float: right;
+margin-top: 10px;
+margin-right: 20px;
+}
+div#header-links {
+border-left: solid 2px #4C721D;
+border-right: solid 2px #4C721D;
+height: 35px;
+padding-left: 70px;
+padding-right: 20px;
+padding-top: 0px;
+background-image: url(images/header-links-bg.gif);
+background-repeat: no-repeat;
+background-position: left top;
+background-attachment: scroll;
+}
+div#header-links table {
+height: 30px;
+
+}
+div#header-links table td {
+}
+div#header-links table td a {
+display: block;
+text-decoration: none;
+color: #fff;
+padding-left: 15px;
+padding-right: 15px;
+padding-top: 7px;
+background-image: url(images/header-link-bg.gif);
+background-repeat: repeat-x;
+background-position: left top;
+background-attachment: scroll;
+height: 23px;
+font-size: 12px;
+font-weight: bold;
+}
+div#header-links table td a:hover {
+background-image: url(images/header-link-bg-hover.gif);
+background-repeat: repeat-x;
+background-position: left top;
+background-attachment: scroll;
+}
+div#middle {
+background-image: url(images/middle-bg.gif);
+background-repeat: repeat-y;
+background-position: left top;
+background-attachment: scroll;
+background-color: #fff;
+min-height: 300px;
+padding-left: 40px;
+padding-right: 40px;
+padding-top: 20px;
+padding-bottom: 20px;
+}
+div#middle div.main-title {
+border-bottom: solid 1px #4C721D;
+text-align: right;
+vertical-align: bottom;
+height: 30px;
+margin-bottom: 20px;
+}
+div#middle div.main-title h1{
+margin-top: 0px;
+padding-top: 0px;
+font-size: 22px;
+color: #4C721D;
+float: left;
+}
+div#middle div.main-title span.time {
+}
+div.left {
+width: 400px;
+}
+div.right {
+border: solid 1px #4C721D;
+margin-left: 40px;
+width: 373px;
+}
+div.right p {
+padding-left: 10px;
+padding-right: 10px;
+}
+div.right h3{
+margin: 0px;
+background-color: #4C721D;
+color: #fff;
+padding: 5px;
+font-size: 12px;
+}
+
+div.login {
+text-align: center;
+}
+div.login table {
+margin: auto;
+font-size: 12px;
+}
+div.login p.new-user {
+font-size: 12px;
+font-weight: bold;
+}
+div.quotes {
+text-align: center;
+width: auto;
+margin: auto;
+}
+div#middle table.normal {
+margin-bottom: 20px;
+}
+div#middle table.normal tr{
+text-align: left;
+font-size: 12px;
+}
+div#middle table.normal tr th {
+font-size: 12px;
+border-bottom: solid 1px #333;
+border-left: 0px;
+border-right: 0px;
+border-top: 0px;
+padding-bottom: 3px;
+color: #4C721D;
+}
+div#middle table.normal tr td.left {
+text-align: right;
+color: #4C721D;
+padding-top: 3px;
+vertical-align: top;
+}
+
+table.table-inner {
+border: solid 1px #999;
+width: 100%;
+}
+table.table-inner tr td,th{
+border: solid 1px #333;
+padding: 5px;
+}
+table.table-inner tr th {
+background-color: #999;
+color: #fff;
+}
+table.table-inner tbody tr td {
+background-color: #ccc;
+text-align: right;
+}
+
+table.table-outer {
+border: solid 0px #333;
+width: auto;
+}
+table.table-outer tr td,th{
+ border: solid 1px #fff;
+ padding: 5px;
+}
+table.table-outer thead tr th {
+background-color: #999;
+border: solid 1px #fff;
+color: #fff;
+padding: 3px;
+}
+table.table-outer tbody tr td {
+background-color: #ededed;
+text-align: center;
+}
+table.table-outer tbody tr td.special {
+background-color: #ccc;
+font-weight: bold;
+text-align: left;
+}
+table.table-outer tbody tr td.currency {
+text-align: right;
+}
+table.table-outer tbody tr.total td{
+background-color: #BCBEC0;
+font-weight: bold;
+text-align: right;
+}
+span.price {
+color: #5E8823;
+}
+span.price-gain {
+color: #5E8823;
+background-image: url(images/green-arrow.gif);
+background-repeat: no-repeat;
+background-position: right top;
+background-attachment: scroll;
+padding-right: 17px;
+}
+span.price-loss {
+color: #C0272D;
+background-image: url(images/red-arrow.gif);
+background-repeat: no-repeat;
+background-position: right bottom;
+background-attachment: scroll;
+padding-right: 17px;
+}
+table.profile {
+border: solid 1px #5E8823;
+width: 100%;
+margin-top: 15px;
+background-color: #ededed;
+}
+table.profile tr td,th{
+padding: 2px;
+}
+table.profile thead tr th {
+color: #5E8823;
+border-bottom: solid 1px #5E8823;
+font-size: 12px;
+padding: 5px;
+}
+table.profile tbody tr td {
+background-color: #ededed;
+text-align: right;
+}
+table.profile tbody tr td.button {
+text-align: center;
+padding: 7px;
+}
+table.profile-content {
+width: auto;
+margin-bottom: 10px;
+}
+table.profile-content tbody tr td {
+padding: 5px;
+border: solid 1px #999;
+}
+table.profile-content tbody tr td.left {
+color: #4C721D;
+}
+table.glossary {
+width: 80%;
+background-color: #ccc;
+}
+table.glossary thead tr th {
+background-color: #666;
+color: #fff;
+border: 0px;
+padding: 5px;
+}
+table.glossary tbody tr td {
+background-color: #fff;
+padding: 5px;
+}
+table.glossary td.left {
+font-weight: bold;
+}
+div#confirm {
+margin-top: 7%;
+margin-bottom: 7%;
+width: 60%;
+margin-left: auto;
+margin-right: auto;
+}
+div#confirm h2 {
+color: #4C721D;
+text-align: center;
+font-size: 18px;
+}
+div#confirm div.confirm-content {
+background-color: #DBEBC6;
+border-top: solid 1px #78A22F;
+border-left: solid 1px #78A22F;
+border-right: solid 2px #78A22F;
+border-bottom: solid 2px #78A22F;
+padding-top: 10px;
+padding-bottom: 20px;
+padding-left: 20px;
+padding-right: 20px;
+text-align: center;
+}
+div.bottom {
+margin-top: 10px;
+border-top: solid 1px #5E8823;
+padding-top: 10px;
+padding-bottom: 0px;
+text-align: center;
+vertical-align: middle;
+}
+div#footer {
+background-image: url(images/footer-bg.gif);
+background-repeat: no-repeat;
+background-position: left top;
+background-attachment: scroll;
+background-color: #fff;
+height: 30px;
+padding-top: 25px;
+padding-left: 20px;
+color: #4C721D;
+}
Added: incubator/stonehenge/contrib/stocktrader/php/trader_client/wsdl/TradeServiceWcf.svc.wsdl
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/php/trader_client/wsdl/TradeServiceWcf.svc.wsdl?rev=720795&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/php/trader_client/wsdl/TradeServiceWcf.svc.wsdl (added)
+++ incubator/stonehenge/contrib/stocktrader/php/trader_client/wsdl/TradeServiceWcf.svc.wsdl Wed Nov 26 02:49:04 2008
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions name="TradeServiceWcf" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://trade.samples.websphere.ibm.com" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
+ <wsdl:import namespace="http://trade.samples.websphere.ibm.com" location="TradeServiceWcf.svc.wsdl0"/>
+ <wsdl:types/>
+ <wsdl:binding name="BasicHttpBinding_ITradeServices" type="i0:ITradeServices">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="emptyMethodAction">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="isOnline">
+ <soap:operation soapAction="isOnline" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="login">
+ <soap:operation soapAction="http://trade.samples.websphere.ibm.com/ITradeServices/login" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getOrders">
+ <soap:operation soapAction="getOrders" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountData">
+ <soap:operation soapAction="getAccountData" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountProfileData">
+ <soap:operation soapAction="getAccountProfileData" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="updateAccountProfile">
+ <soap:operation soapAction="updateAccountProfile" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="logout">
+ <soap:operation soapAction="logout" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="buy">
+ <soap:operation soapAction="buy" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sell">
+ <soap:operation soapAction="sell" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getHoldings">
+ <soap:operation soapAction="getHoldings" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="register">
+ <soap:operation soapAction="register" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getClosedOrders">
+ <soap:operation soapAction="getClosedOrders" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMarketSummary">
+ <soap:operation soapAction="getMarketSummary" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="http://trade.samples.websphere.ibm.com/ITradeServices/getQuote" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getHolding">
+ <soap:operation soapAction="getHolding" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getTopOrders">
+ <soap:operation soapAction="getTopOrders" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sellEnhanced">
+ <soap:operation soapAction="sellEnhanced" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="TradeServiceWcf">
+ <wsdl:port name="BasicHttpBinding_ITradeServices" binding="tns:BasicHttpBinding_ITradeServices">
+ <soap:address location="http://diluka/TradeServiceWcf/TradeServiceWcf.svc"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>