Author: shankar Date: Wed Feb 11 04:07:29 2009 New Revision: 743209 URL: http://svn.apache.org/viewvc?rev=743209&view=rev Log: PHP order processor added.
Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/ incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/ incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/database_config.xml incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/policy.xml incubator/stonehenge/trunk/stocktrader/php/order_processor/data_access_layer.php incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/ incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/alice_cert.cert incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_cert.cert incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_key.pem incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc.php incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc_msec.php incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/ incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl0 incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd0 incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd1 incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd2 Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/database_config.xml URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/database_config.xml?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/database_config.xml (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/database_config.xml Wed Feb 11 04:07:29 2009 @@ -0,0 +1,6 @@ +<config> + <server>127.0.0.1,1433</server> + <user>trade</user> + <password>trade</password> + <database>StockTraderDB</database> +</config> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/policy.xml URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/policy.xml?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/policy.xml (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/conf/policy.xml Wed Feb 11 04:07:29 2009 @@ -0,0 +1,43 @@ +<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:ProtectionToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssX509V3Token10/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:ProtectionToken> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic256/> + </wsp:Policy> + </sp:AlgorithmSuite> + <sp:Layout> + <wsp:Policy> + <sp:Strict/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + </wsp:Policy> + </sp:SymmetricBinding> + <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:MustSupportRefKeyIdentifier/> + <sp:MustSupportRefEmbeddedToken/> + <sp:MustSupportRefIssuerSerial/> + </wsp:Policy> + </sp:Wss10> + <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <sp:Body/> + </sp:SignedParts> + <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <sp:Body/> + </sp:EncryptedParts> + </wsp:All> + </wsp:ExactlyOne> +</wsp:Policy> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/data_access_layer.php URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/data_access_layer.php?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/data_access_layer.php (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/data_access_layer.php Wed Feb 11 04:07:29 2009 @@ -0,0 +1,123 @@ +<?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. + */ + + +/** + * This class encapsulates information regarding the establishment + * of database connection. + */ + +class ConnectionInfo +{ + public $server; //The database server (eg: 127.0.0.1:1433) + public $user; //User name + public $password; //Password + public $database; //Database name +} + +/** + * The method retrieves information for the database connection + * from a configuration file. The name of the config file should + * be, database_config.xml, and it should be in the same directory + * as this file. + * @return non NULL value (ConnectionInfo object), upon successfull + * execution, and NULL if some information regarding the + * connection is not available. + */ + +function GetConnectionInfo() +{ + $doc = new DOMDocument(); + $result = $doc->load('database_config.xml'); + + $server = $doc->getElementsByTagName("server")->item(0)->nodeValue; + $user = $doc->getElementsByTagName("user")->item(0)->nodeValue; + $password = $doc->getElementsByTagName("password")->item(0)->nodeValue; + $database = $doc->getElementsByTagName("database")->item(0)->nodeValue; + + if ($server == NULL || $user == NULL || $password == NULL || $database == NULL) + { + error_log ("SERVER, USER, PASSWORD OR DATABASE IS NULL\n"); + } + else + { + $ConnInfo = new ConnectionInfo(); + $ConnInfo->server = $server; + $ConnInfo->user = $user; + $ConnInfo->password = $password; + $ConnInfo->database = $database; + } + return $ConnInfo; +} + +/** + * This method establishes a connection to the database. + * @return dbhandle, upon successfull execution a non null + * handle to the database connection is returned. Else it + * will be null. + */ + +function ConnectToDatabase() +{ + $connInfo = GetConnectionInfo(); + if ($connInfo != NULL) + { + $dbhandle = mssql_connect($connInfo->server, $connInfo->user, $connInfo->password) + or die ("Couldn't connect to the server!!!"); + $selected = mssql_select_db($connInfo->database, $dbhandle) + or die ("Couldn't open the database!!!"); + } + return $dbhandle; +} + +/** + * This method executes a query that it receives. + * @param query the query to execute + * @return non-NULL upon success and NULL otherwise. + */ + +function ExecuteQuery($query) +{ + return mssql_query($query); +} + +/** + * This method close the connection that is established to the + * database. + * @param dbhandle handle to the database + */ + +function CloseDatabase($dbhandle) +{ + mssql_close($dbhandle); +} + +/** + * This method returns the a value from a mssql result set (a tuple + * returned after execution of ExecuteQuery method. + * @param result, the result obtained from ExecuteQuery method. + * @param raw, the raw number + * @param column, the column number + * @return the value at (raw, column) of the tuple. + */ + +function GetMSSQLValue($result, $raw, $column) +{ + return mssql_result($result, $raw, $column); +} +?> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/alice_cert.cert URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/alice_cert.cert?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/alice_cert.cert (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/alice_cert.cert Wed Feb 11 04:07:29 2009 @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDDCCAfSgAwIBAgIQM6YEf7FVYx/tZyEXgVComTANBgkqhkiG9w0BAQUFADAw +MQ4wDAYDVQQKDAVPQVNJUzEeMBwGA1UEAwwVT0FTSVMgSW50ZXJvcCBUZXN0IENB +MB4XDTA1MDMxOTAwMDAwMFoXDTE4MDMxOTIzNTk1OVowQjEOMAwGA1UECgwFT0FT +SVMxIDAeBgNVBAsMF09BU0lTIEludGVyb3AgVGVzdCBDZXJ0MQ4wDAYDVQQDDAVB +bGljZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAoqi99By1VYo0aHrkKCNT +4DkIgPL/SgahbeKdGhrbu3K2XG7arfD9tqIBIKMfrX4Gp90NJa85AV1yiNsEyvq+ +mUnMpNcKnLXLOjkTmMCqDYbbkehJlXPnaWLzve+mW0pJdPxtf3rbD4PS/cBQIvtp +jmrDAU8VsZKT8DN5Kyz+EZsCAwEAAaOBkzCBkDAJBgNVHRMEAjAAMDMGA1UdHwQs +MCowKKImhiRodHRwOi8vaW50ZXJvcC5iYnRlc3QubmV0L2NybC9jYS5jcmwwDgYD +VR0PAQH/BAQDAgSwMB0GA1UdDgQWBBQK4l0TUHZ1QV3V2QtlLNDm+PoxiDAfBgNV +HSMEGDAWgBTAnSj8wes1oR3WqqqgHBpNwkkPDzANBgkqhkiG9w0BAQUFAAOCAQEA +BTqpOpvW+6yrLXyUlP2xJbEkohXHI5OWwKWleOb9hlkhWntUalfcFOJAgUyH30TT +pHldzx1+vK2LPzhoUFKYHE1IyQvokBN2JjFO64BQukCKnZhldLRPxGhfkTdxQgdf +5rCK/wh3xVsZCNTfuMNmlAM6lOAg8QduDah3WFZpEA0s2nwQaCNQTNMjJC8tav1C +Br6+E5FAmwPXP7pJxn9Fw9OXRyqbRA4v2y7YpbGkG2GI9UvOHw6SGvf4FRSthMMO +35YbpikGsLix3vAsXWWi4rwfVOYzQK0OFPNi9RMCUdSH06m9uLWckiCxjos0FQOD +ZE9l4ATGy9s9hNVwryOJTw== +-----END CERTIFICATE----- Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_cert.cert URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_cert.cert?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_cert.cert (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_cert.cert Wed Feb 11 04:07:29 2009 @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDCjCCAfKgAwIBAgIQYDju2/6sm77InYfTq65x+DANBgkqhkiG9w0BAQUFADAw +MQ4wDAYDVQQKDAVPQVNJUzEeMBwGA1UEAwwVT0FTSVMgSW50ZXJvcCBUZXN0IENB +MB4XDTA1MDMxOTAwMDAwMFoXDTE4MDMxOTIzNTk1OVowQDEOMAwGA1UECgwFT0FT +SVMxIDAeBgNVBAsMF09BU0lTIEludGVyb3AgVGVzdCBDZXJ0MQwwCgYDVQQDDANC +b2IwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMCquMva4lFDrv3fXQnKK8Ck +SU7HvVZ0USyJtlL/yhmHH/FQXHyYY+fTcSyWYItWJYiTZ99PAbD+6EKBGbdfuJNU +JCGaTWc5ZDUISqM/SGtacYe/PD/4+g3swNPzTUQAIBLRY1pkr2cm3s5Ch/f+mYVN +BR41HnBeIxybw25kkoM7AgMBAAGjgZMwgZAwCQYDVR0TBAIwADAzBgNVHR8ELDAq +MCiiJoYkaHR0cDovL2ludGVyb3AuYmJ0ZXN0Lm5ldC9jcmwvY2EuY3JsMA4GA1Ud +DwEB/wQEAwIEsDAdBgNVHQ4EFgQUXeg55vRyK3ZhAEhEf+YT0z986L0wHwYDVR0j +BBgwFoAUwJ0o/MHrNaEd1qqqoBwaTcJJDw8wDQYJKoZIhvcNAQEFBQADggEBAIiV +Gv2lGLhRvmMAHSlY7rKLVkv+zEUtSyg08FBT8z/RepUbtUQShcIqwWsemDU8JVts +ucQLc+g6GCQXgkCkMiC8qhcLAt3BXzFmLxuCEAQeeFe8IATr4wACmEQE37TEqAuW +EIanPYIplbxYgwP0OBWBSjcRpKRAxjEzuwObYjbll6vKdFHYIweWhhWPrefquFp7 +TefTkF4D3rcctTfWJ76I5NrEVld+7PBnnJNpdDEuGsoaiJrwTW3Ixm40RXvG3fYS +4hIAPeTCUk3RkYfUkqlaaLQnUrF2hZSgiBNLPe8gGkYORccRIlZCGQDEpcWl1Uf9 +OHw6fC+3hkqolFd5CVI= +-----END CERTIFICATE----- Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_key.pem URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_key.pem?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_key.pem (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/keys/bob_key.pem Wed Feb 11 04:07:29 2009 @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDAqrjL2uJRQ679310JyivApElOx71WdFEsibZS/8oZhx/xUFx8 +mGPn03EslmCLViWIk2ffTwGw/uhCgRm3X7iTVCQhmk1nOWQ1CEqjP0hrWnGHvzw/ ++PoN7MDT801EACAS0WNaZK9nJt7OQof3/pmFTQUeNR5wXiMcm8NuZJKDOwIDAQAB +AoGBAL9MxBAlVXG68pXAonCF/MtaVC+Uw7qD49WFJzNiJxkRwfWpBSvxY8FbgJP0 +/Addkgb51bk0iUlk0Ni3twEMWga0j9jOJLkDDoXfpHmH5HGTvNa9m241PGQ+kzAU +dFvFzR0qUTDlBjk4pYoeqoJBTgNZGu3b3BHEbz7O7PAJUQEBAkEA8Rwrf7/pSiPH +2pfU5StQ77+1Uva5VHpDoKLC5mgAgiPvQm2yBBSXkwPwXHEeRYEOfHydtCrudQY3 +6fVP4Oy1GQJBAMyQsI6CIjEwZzS1KXLb+ulpFBjcK99PydBGKxRue/o0ZpD69siA +AL4YqyXl4Ai4hEHHe7FxeJe4Wzp6F0A6kXMCQQCpC8QfzHEHTzDnPP7CMm2LupCp ++1wTM6nIrXUS0CZTGFi+7WQbYkinheJ3HcRInOSIOWLkmBkaKWL4gMshezS5AkB8 +1G5pCBBFY/wWtdYtOP/MH0scQH6lLtNAPRFczm7pJ8DPB9ZAU5wgZH1MCxLDP5W1 +bj2U8mFcdCt3a7l0gEjxAkEAwoWqq6i7ZfFg4LUcKElZhjMeF8tKs1fWHhunO80t +6hQUhBHahc4+AAgoXOMe+KAxa+F6uftjM9eg8rAAZ+6q3g== +-----END RSA PRIVATE KEY----- Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php Wed Feb 11 04:07:29 2009 @@ -0,0 +1,523 @@ +<?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 ("data_access_layer.php"); + +define ("ORDER_TYPE_BUY", "buy"); +define ("ORDER_TYPE_SELL", "sell"); +define ("ORDER_STATUS_CLOSED", "closed"); +define ("STATUS_SUCCESS", 1); //This represents a success status. +define ("STATUS_FAILURE", 0); //This represents a failure status. +define ("INVALID_ID", -1); //Since Account ID 0 is valid, we used -1 + //to denote invalid + +/** + * This class encapsulates information regarding an order object. + */ + +class OrderDataBean +{ + public $orderID; // int + public $orderType; // string (buy | sell) + public $orderStatus; // string (closed | completed | open) + public $openDate; // dateTime + public $completionDate; // dateTime + public $quantity; // double + public $price; // decimal + public $orderFee; // decimal + public $symbol; // string +} + +/** + * This class encapsulates an order object, and it contains information + * regarding a SubmitOrder request. + */ + +class SubmitOrder +{ + public $order; // OrderDataBean +} + +/** + * This class encapsulates information regarding a particular holding. + * Each buy order creates a holding object and stores an entry in the + * holding table. + */ + +class Holding +{ + public $purchasePrice; //decimal + public $holdingID; //int + public $quantity; //double + public $purchaseDate; //dateTime + public $accountID; //string + public $quoteSymbol; //string +} + +/** + * This class encapsulate information regarding a particular quote. The + * quote information related to a particular symbol, have to be analyzed + * in order to process an order. + */ + +class Quote +{ + public $low; //decimal + public $open1; //decimal + public $volume; //double + public $price; //decimal + public $high; //decimal + public $symbol; //string + public $change1; //decimal +} + +/** + * This is the primary function which corresponds to the SubmitOrder + * operation. + */ + +function ProcessOrder($order) +{ + $status = STATUS_SUCCESS; + $dbhandle = ConnectToDatabase(); + + /*This method with "BEGIN TRAN" initialize a transaction; which privides + control so that later we can cancel a the transaction, if something + goes wrong.*/ + + $status = ExecuteQuery("BEGIN TRAN"); + if ($status) + { + $quote = GetQuoteForUpdate($order->symbol); + if ($quote) + { + $order->price = $quote->price; + + /*Buy or sell orders either first creates a holding or sell a + holding. The return value is the holdingID upon success. If NULL + is returned, then the tranaction can not be completed. This is due + to either problem of accessing the database or if there is no + maching holding.*/ + + /*upon success, total price should be deducted from account's balance. + In case of sell, balance should increase. So, in sell case, total price will be + negative value */ + + if ($order->orderType == ORDER_TYPE_BUY) + { + $holdingID = CreateHolding($order); + if ($holdingID != INVALID_ID) + { + $totalPrice = + $order->quantity * $order->price + $order->orderFee; + } + } + if ($order->orderType == ORDER_TYPE_SELL) + { + $holdingID = SellHolding($order); + if ($holdingID != INVALID_ID) + { + $totalPrice = -1 * $order->quantity * $order->price + + $order->orderFee; + } + } + + if ($holdingID != INVALID_ID) + { + $status = UpdateSystemStatus($order, + $quote, $holdingID, $totalPrice); + } + else + { + error_log ("Holding id for order with order id ".$order->orderID. " is not valid\n"); + $status = STATUS_FAILURE; + } + } + else + { + error_log ("Cannot get quote with symbol ".$order->symbol. "\n"); + $status = STATUS_FAILURE; + } + + } + if ($status == STATUS_SUCCESS) + { + /*Transaction is successfull, we can safely commit the transaction + into the database.*/ + + ExecuteQuery("COMMIT TRAN"); + } + else + { + /*Transaction is not successfull, we can safely rollback the + transaction without commiting to the database.*/ + + ExecuteQuery("ROLLBACK TRAN"); + } + CloseDatabase($dbhandle); +} + +/** + * This method, retrieves all the information related to a particular symbol + * from the QUOTE table. + * @param symbol is the symbol we are looking for + * @return quote object filled with symbol information upons success and else + * NULL is returned. + */ + +function GetQuoteForUpdate($symbol) +{ + $query = "Set NOCOUNT ON; SELECT SYMBOL, COMPANYNAME, VOLUME, PRICE, ". + "OPEN1, LOW, HIGH, CHANGE1 FROM QUOTE WITH (NOLOCK) WHERE SYMBOL ". + "= '$symbol'"; + + /*Get the tuple corresponding to the particular symbol*/ + + $result = ExecuteQuery($query); + if ($result) + { + $quote = new Quote(); + $quote->symbol = GetMSSQLValue($result, 0, 0); //Get the symbol. + $quote->price = GetMSSQLValue($result, 0, 3); //Get the price. + $quote->low = GetMSSQLValue($result, 0, 5); //Get the low value. + $quote->high = GetMSSQLValue($result, 0, 6); //Get the high value. + } + return $quote; +} + +/** + * This method updates all the system information relates to a particular + * buy or sell operation. + * @param order order object + * @param quote quote object + * @param holdingID holdingID of the holding which relates to the current order + * @param totalPrice the price change (amount of money the flows in/out of a + * user's account). + * @return STATUS_SUCCESS upon success and STATUS_FAILURE otherwise. + */ + +function UpdateSystemStatus($order, $quote, $holdingID, $totalPrice) +{ + $status = STATUS_SUCCESS; + $accountID = GetAccountIDFromOrder($order); + if ($accountID != INVALID_ID) + { + if(UpdateAccountBalance($accountID, $totalPrice)) + { + if(UpdateStockPriceVolume($order->quantity, $quote)) + { + if(!CloseOrder($order, $holdingID)) + { + error_log ("Cannot close order for order id ". $order->orderID. " \n"); + $status = STATUS_FAILURE; + } + } + else + { + error_log ("Cannot update stock price volume for symbol ". $quote->symbol. "\n"); + $status = STATUS_FAILURE; + } + } + else + { + error_log ("Cannot update account balace for account id ".$accountID. "\n"); + $status = STATUS_FAILURE; + } + } + else + { + error_log ("Account id for order id " .$order->orderID. " is not valid \n"); + $status = STATUS_FAILURE; + } + return $status; +} + +/** + * This function corresponds to a sell operation. It matches a particular + * holding related to a particular order (symbol) and then do the transaction + * @param order order object + * @return a non NULL holdingID upon success and NULL otherwise. + */ + +function SellHolding($order) +{ + $holding = GetHoldingForUpdate($order); + if ($holding) + { + $accountID = $holding->accountID; + $quantity = $order->quantity; + $holdingQuantity = $holding->quantity; + + if ($order->quantity < $holding->quantity) + { + if(!UpdateHolding($holding, $order->quantity)) + { + error_log ("Cannot update holding with holding id ".$holding->holdingID. " \n"); + $holding->holdingID = INVALID_ID; + } + } + else if ($order->quantity == $holding->quantity) + { + if(!DeleteHolding($holding)) + { + error_log ("Cannot delete holding with holding id ".$holding->holdingID. " \n"); + $holding->holdingID = INVALID_ID; + } + } + else + { + if(!DeleteHolding($holding)) + { + error_log ("Cannot delete holding with holding id ".$holding->holdingID. " \n"); + $holding->holdingID = INVALID_ID; + } + else + { + $order->quantity = $holding->quantity; + if(!UpdateOrder($order)) + { + error_log ("Cannot update order with order id ".$order->orderID. " \n"); + $holding->holdingID = INVALID_ID; + } + } + } + } + else + { + error_log ("Holding for order id ".$order->orderID. " is not valid \n"); + return INVALID_ID; + } + return $holding->holdingID; +} + +/** + * This method updates the status of an order as a result of a buy or sell + * operation. + * @param order order object + * @return NON-NULL on success and NULL on failure. + */ + +function UpdateOrder($order) +{ + $query = "UPDATE ORDERS WITH (ROWLOCK) SET QUANTITY='$order->quantity' WHERE". + " ORDERID='$order->orderID'"; + return ExecuteQuery($query); +} + +/** + * This method updates a particular Holing entry in the HOLDING table. + * @param holding is the holding object. + * @param quantity is the amount of buy or sell. + * $return NON-NULL on success or NULL otherwise. + */ + +function UpdateHolding($holding, $quantity) +{ + $query = "UPDATE HOLDING WITH (ROWLOCK) SET QUANTITY=QUANTITY-'$quantity'". + " WHERE HOLDINGID='$holding->holdingID'"; + return ExecuteQuery($query); +} + +/** + * Removes an entry from the HOLDING table when a matching order is received. + * @param holding is a holding object. + * @return NON-NULL value on success and NULL otherwise. + */ + +function DeleteHolding($holding) +{ + $query = "DELETE FROM HOLDING WITH (ROWLOCK) WHERE ". + "HOLDINGID='$holding->holdingID'"; + return ExecuteQuery($query); +} + +/** + * This method returns a quote object which matches to the particular sell + * order. + * @param order the order object. + * @return a Holding object upon success and NULL otherwise. + */ + +function GetHoldingForUpdate($order) +{ + $query = "Set NOCOUNT ON; SELECT HOLDING.HOLDINGID, HOLDING.ACCOUNT_ACCOUNTID,". + " HOLDING.QUANTITY, HOLDING.PURCHASEPRICE, HOLDING.PURCHASEDATE,". + " HOLDING.QUOTE_SYMBOL FROM HOLDING WITH (ROWLOCK) INNER JOIN ORDERS". + " ON HOLDING.HOLDINGID = ORDERS.HOLDING_HOLDINGID WHERE ". + "(ORDERS.ORDERID = '$order->orderID')"; + + /*Get the machining tuple from HOLDING table, that corresponds to the + current sell operation.*/ + + $result = ExecuteQuery($query); + + if ($result) + { + $holding = new Holding(); + $holding->holdingID = GetMSSQLValue($result, 0, 0); //Get the holdingID. + $holding->accountID = GetMSSQLValue($result, 0, 1); //Get the accountID. + $holding->quantity = GetMSSQLValue($result, 0, 2); //Get the quantity. + $holding->purchasePrice = GetMSSQLValue($result, 0, 3); //Get the price. + $holding->purchaseDate = GetMSSQLValue($result, 0, 4); //Get the date. + $holding->quoteSymbol = GetMSSQLValue($result, 0, 5); //Get the symbol. + } + else + { + error_log ("Cannot obtain holding for order id ". $order->orderID . "\n"); + } + return $holding; +} + +/** + * This method updates the order status, with newest settings on completion + * of processing an order. + * @param order order object. + * @param holdingID holdingID of the particular holding. + * @return NON-NULL on success and NULL on failure. + */ + +function CloseOrder($order, $holdingID) +{ + $order->orderStatus = ORDER_STATUS_CLOSED; + if ($order->orderType == ORDER_TYPE_SELL) + { + $holdingID = NULL; + } + $query = "UPDATE ORDERS WITH (ROWLOCK) SET ". + "ORDERSTATUS='".ORDER_STATUS_CLOSED."',". + " COMPLETIONDATE=GetDate(), HOLDING_HOLDINGID='$holdingID',". + " PRICE='$order->price' WHERE ORDERID='$order->orderID'"; + return ExecuteQuery($query); +} + +/** + * Create an entry in the HOLDING table to represent a particular buy order. + * @param order order object filled with order information. + * @return the holdingID of the created holding upon success and else it + * returns NULL + */ + +function CreateHolding($order) +{ + $accountID = GetAccountIDFromOrder($order); + if ($accountID != INVALID_ID) + { + $query = "INSERT INTO HOLDING (PURCHASEPRICE, QUANTITY, PURCHASEDATE,". + " ACCOUNT_ACCOUNTID, QUOTE_SYMBOL) VALUES ('$order->price',". + " '$order->quantity', GetDate(), '$accountID', '$order->symbol');". + " SELECT ID=@@IDENTITY"; + $result = ExecuteQuery($query); + if ($result) + { + $holdingID = GetMSSQLValue($result, 0, 0); + } + else + { + error_log ("Cannot create holding for order id ". $order->orderID . "\n"); + $holdingID = INVALID_ID; + } + } + else + { + error_log ("Account id for order with order id ".$order->orderID. " is not valid\n"); + $holdingID = INVALID_ID; + } + return $holdingID; +} + +/** + * This method retrieves the acccountID from a given order. + * @param order the order object. + * @return NON-NULL accountID upon success and NULL otherwise. + */ + +function GetAccountIDFromOrder($order) +{ + $query = "Set NOCOUNT ON; SELECT ACCOUNT_ACCOUNTID FROM ORDERS WITH ". + "(NOLOCK) WHERE ORDERID='$order->orderID'"; + + /*Get a tuple including accountID for a particular order*/ + + $result = ExecuteQuery($query); + if ($result != NULL) + { + $accountID = GetMSSQLValue($result, 0, 0); //Get accountID. + } + else + { + error_log ("Cannot obtain account id for order with order id ".$order->orderID. "\n"); + $accountID = INVALID_ID; + } + return $accountID; +} + +/** + * This method updates the account balance of the user who buy or sell some + * sybmol. + * @param accountID is the account to be updated. + * @param amount the amount of money by which the account is updated. + * @return NON-NULL upon success and NULL on failure. + */ + +function UpdateAccountBalance($accountID, $amount) +{ + $query = "UPDATE ACCOUNT WITH (ROWLOCK) SET BALANCE=(BALANCE - '$amount')". + " WHERE ACCOUNTID = '$accountID'"; + return ExecuteQuery($query); +} + +/** + * This method updates the QUOTE table with the new price values. In here, a + * random value is generated which is between 0.1 and 2, and then the quote + * price is changed by multiplying it with the generted random value. + * @param quantity the quantity of a particular symbol the client buy or sell. + * @return STATUS_SUCCESS upon success and STATUS_FAILURE upon failure. + */ + +function UpdateStockPriceVolume($quantity, $quote) +{ + if ($quote) + { + $rand = rand(1, 20); + $priceChangeFactor = ((float)$rand)/10; + $quote->price = $quote->price * $priceChangeFactor; + + if($quote->price < 0.05 || $quote->price > 1000) + { + $quote->price = 100; + } + + if ($quote->price < $quote->low) + { + $quote->low = $quote->price; + } + if ($quote->price > $quote->high) + { + $quote->high = $quote->price; + } + + $query = "UPDATE QUOTE WITH (ROWLOCK) SET PRICE='$quote->price', ". + "LOW='$quote->low', HIGH='$quote->high', CHANGE1='$quote->price' - ". + "OPEN1, VOLUME=VOLUME+'$quantity' WHERE SYMBOL='$quote->symbol'"; + + $status = ExecuteQuery($query); + } + return $status; +} +?> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc.php URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc.php?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc.php (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc.php Wed Feb 11 04:07:29 2009 @@ -0,0 +1,100 @@ +<?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 ("order_processor.php"); + +// define the class map +$class_map = array("anyType" => "anyType", "OrderDataBean" => "OrderDataBean", + "SubmitOrder" => "SubmitOrder", "isOnline" => "isOnline"); + +class isOnline +{ +} + + +/** + * This method corresponds to the primary operation of the service.It processes + * an incomming order object. + * @param input, the order object, filled with data correspond to an order + * @return accept upon success. + */ + +function SubmitOrder($input) +{ + SendAcceptNotification(); + if ($input->order != NULL) + { + if(($input->order->orderType == ORDER_TYPE_BUY) || + ($input->order->orderType == ORDER_TYPE_SELL)) + { + ProcessOrder($input->order); + } + else + { + error_log ("Incoming order type is incorrect.\n"); + } + } + else + { + error_log ("Incoming order request is NULL.\n"); + } +} + +/** + * This method obtains some additional time and let the business service + * to store information regarding an order. Then the OrderProcessor can + * continue processing the order request that was just stored in the + * database. + */ + +function SendAcceptNotification() +{ + header('HTTP/1.1 202 Accepted'); + header('Content-Length: 0'); + flush(); + sleep(1); +} + +/** + * This function corresponds to the isOnline operation. This is used by the + * Configuration service to make sure that the OrderProcessor service is + * online. + * @return just a return is expected to make sure the service is online. + */ + +function isOnline($input) +{ + return; +} + +// define the operations map +$operations = array("SubmitOrder" => "SubmitOrder", "isOnline" => "isOnline"); + +// define the actions => operations map +$actions = array("SubmitOrderOnePhase" => "SubmitOrder", + "isOnline" => "isOnline"); + +// create service in WSDL mode +$service = new WSService(array ("wsdl" =>"./wsdl/TradeOrders.wsdl", + "operations" => $operations, + "actions" => $actions, + "classmap" => $class_map,)); + +// process client requests and reply +$service->reply(); +?> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc_msec.php URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc_msec.php?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc_msec.php (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor_svc_msec.php Wed Feb 11 04:07:29 2009 @@ -0,0 +1,108 @@ +<?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 ("order_processor.php"); + +// define the class map +$class_map = array("anyType" => "anyType", "OrderDataBean" => "OrderDataBean", + "SubmitOrder" => "SubmitOrder", "isOnline" => "isOnline"); + +class isOnline +{ +} + + +/** + * This method corresponds to the primary operation of the service.It processes + * an incomming order object. + * @param input, the order object, filled with data correspond to an order + * @return accept upon success. + */ + +function SubmitOrder($input) +{ + SendAcceptNotification(); + if ($input->order != NULL) + { + if(($input->order->orderType == ORDER_TYPE_BUY) || + ($input->order->orderType == ORDER_TYPE_SELL)) + { + ProcessOrder($input->order); + } + else + { + error_log ("Incoming order type is incorrect.\n"); + } + } + else + { + error_log ("Incoming order request is NULL.\n"); + } +} + +/** + * This method obtains some additional time and let the business service + * to store information regarding an order. Then the OrderProcessor can + * continue processing the order request that was just stored in the + * database. + */ + +function SendAcceptNotification() +{ + header('HTTP/1.1 202 Accepted'); + header('Content-Length: 0'); + flush(); + sleep(1); +} + +/** + * This function corresponds to the isOnline operation. This is used by the + * Configuration service to make sure that the OrderProcessor service is + * online. + * @return just a return is expected to make sure the service is online. + */ + +function isOnline($input) +{ + return; +} + +// define the operations map +$operations = array("SubmitOrder" => "SubmitOrder", "isOnline" => "isOnline"); + +// define the actions => operations map +$actions = array("SubmitOrderOnePhase" => "SubmitOrder", + "isOnline" => "isOnline"); + +//This is the security information +$pvt_key = ws_get_key_from_file("./keys/bob_key.pem"); +$policy_xml = file_get_contents("./conf/policy.xml"); +$policy = new WSPolicy($policy_xml); +$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key)); + +// create service in WSDL mode +$service = new WSService(array ("wsdl" =>"./wsdl/TradeOrders.wsdl", + "operations" => $operations, + "actions" => $actions, + "policy" => $policy, + "securityToken" => $sec_token, + "classmap" => $class_map,)); + +// process client requests and reply +$service->reply(); +?> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl Wed Feb 11 04:07:29 2009 @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="utf-8"?> +<wsdl:definitions name="OrderProcessor" targetNamespace="http://Trade.TraderOrderHost" 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://Trade.TraderOrderHost" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://Trade.TraderOrderHost" 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" > + <wsp:Policy wsu:Id="NetMsmqBinding_OrderProcessorService_policy"> + <wsp:ExactlyOne> + <wsp:All> + <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"/> + <wsaw:UsingAddressing/> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + <wsp:Policy wsu:Id="NetMsmqBinding_OrderProcessorService1_policy"> + <wsp:ExactlyOne> + <wsp:All> + <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"/> + <msmq:MsmqVolatile xmlns:msmq="http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"/> + <msmq:MsmqBestEffort xmlns:msmq="http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"/> + <wsaw:UsingAddressing/> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + <wsp:Policy wsu:Id="CustomBinding_OrderProcessorService_policy"> + <wsp:ExactlyOne> + <wsp:All> + <ow:OneWay xmlns:ow="http://schemas.microsoft.com/ws/2005/05/routing/policy"/> + <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"/> + <wsaw:UsingAddressing/> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + <wsdl:types> + <xsd:schema targetNamespace="http://Trade.TraderOrderHost/Imports"> + <xsd:import schemaLocation="TradeOrders.xsd0" namespace="http://Trade.TraderOrderHost"/> + <xsd:import schemaLocation="TradeOrders.xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> + <xsd:import schemaLocation="TradeOrders.xsd2" namespace="http://trade.samples.websphere.ibm.com"/> + </xsd:schema> + </wsdl:types> + <wsdl:message name="OrderProcessorService_SubmitOrderTransactedQueue_InputMessage"> + <wsdl:part name="parameters" element="tns:SubmitOrderTransactedQueue"/> + </wsdl:message> + <wsdl:message name="OrderProcessorService_SubmitOrder_InputMessage"> + <wsdl:part name="parameters" element="tns:SubmitOrder"/> + </wsdl:message> + <wsdl:message name="OrderProcessorService_isOnline_InputMessage"> + <wsdl:part name="parameters" element="tns:isOnline"/> + </wsdl:message> + <wsdl:portType name="OrderProcessorService"> + <wsdl:operation name="SubmitOrderTransactedQueue"> + <wsdl:input wsaw:Action="SubmitOrder" message="tns:OrderProcessorService_SubmitOrderTransactedQueue_InputMessage"/> + </wsdl:operation> + <wsdl:operation name="SubmitOrder"> + <wsdl:input wsaw:Action="SubmitOrderOnePhase" message="tns:OrderProcessorService_SubmitOrder_InputMessage"/> + </wsdl:operation> + <wsdl:operation name="isOnline"> + <wsdl:input wsaw:Action="isOnline" message="tns:OrderProcessorService_isOnline_InputMessage"/> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="BasicHttpBinding_OrderProcessorService" type="i0:OrderProcessorService"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="SubmitOrderTransactedQueue"> + <soap:operation soapAction="SubmitOrder" style="document"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="SubmitOrder"> + <soap:operation soapAction="SubmitOrderOnePhase" style="document"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="isOnline"> + <soap:operation soapAction="isOnline" style="document"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + </wsdl:operation> + </wsdl:binding> + <wsdl:binding name="NetMsmqBinding_OrderProcessorService" type="i0:OrderProcessorService"> + <wsp:PolicyReference URI="#NetMsmqBinding_OrderProcessorService_policy"/> + <soap12:binding transport="http://schemas.microsoft.com/soap/msmq"/> + <wsdl:operation name="SubmitOrderTransactedQueue"> + <soap12:operation soapAction="SubmitOrder" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="SubmitOrder"> + <soap12:operation soapAction="SubmitOrderOnePhase" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="isOnline"> + <soap12:operation soapAction="isOnline" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + </wsdl:binding> + <wsdl:binding name="NetMsmqBinding_OrderProcessorService1" type="i0:OrderProcessorService"> + <wsp:PolicyReference URI="#NetMsmqBinding_OrderProcessorService1_policy"/> + <soap12:binding transport="http://schemas.microsoft.com/soap/msmq"/> + <wsdl:operation name="SubmitOrderTransactedQueue"> + <soap12:operation soapAction="SubmitOrder" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="SubmitOrder"> + <soap12:operation soapAction="SubmitOrderOnePhase" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="isOnline"> + <soap12:operation soapAction="isOnline" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + </wsdl:binding> + <wsdl:binding name="CustomBinding_OrderProcessorService" type="i0:OrderProcessorService"> + <wsp:PolicyReference URI="#CustomBinding_OrderProcessorService_policy"/> + <soap12:binding transport="http://schemas.microsoft.com/soap/tcp"/> + <wsdl:operation name="SubmitOrderTransactedQueue"> + <soap12:operation soapAction="SubmitOrder" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="SubmitOrder"> + <soap12:operation soapAction="SubmitOrderOnePhase" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="isOnline"> + <soap12:operation soapAction="isOnline" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="OrderProcessor"> + <wsdl:port name="BasicHttpBinding_OrderProcessorService" binding="tns:BasicHttpBinding_OrderProcessorService"> + <soap:address location="http://nandika:9010/TradeOrders"/> + </wsdl:port> + <!-- + <wsdl:port name="NetMsmqBinding_OrderProcessorService" binding="tns:NetMsmqBinding_OrderProcessorService"> + <soap12:address location="net.msmq://shankar/private/tradeordersqueuedurable"/> + <wsa10:EndpointReference> + <wsa10:Address>net.msmq://shankar/private/tradeordersqueuedurable</wsa10:Address> + </wsa10:EndpointReference> + </wsdl:port> + <wsdl:port name="NetMsmqBinding_OrderProcessorService1" binding="tns:NetMsmqBinding_OrderProcessorService1"> + <soap12:address location="net.msmq://shankar/private/tradeordersqueuevolatile"/> + <wsa10:EndpointReference> + <wsa10:Address>net.msmq://shankar/private/tradeordersqueuevolatile</wsa10:Address> + </wsa10:EndpointReference> + </wsdl:port> + <wsdl:port name="CustomBinding_OrderProcessorService" binding="tns:CustomBinding_OrderProcessorService"> + <soap12:address location="net.tcp://shankar:9001/TradeOrders"/> + <wsa10:EndpointReference> + <wsa10:Address>net.tcp://shankar:9001/TradeOrders</wsa10:Address> + </wsa10:EndpointReference> + </wsdl:port> + --> + </wsdl:service> +</wsdl:definitions> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl0 URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl0?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl0 (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.wsdl0 Wed Feb 11 04:07:29 2009 @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<wsdl:definitions targetNamespace="http://Trade.TraderOrderHost" 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://Trade.TraderOrderHost" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 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:types> + <xsd:schema targetNamespace="http://Trade.TraderOrderHost/Imports"> + <xsd:import schemaLocation="TradeOrders.xsd0" namespace="http://Trade.TraderOrderHost"/> + <xsd:import schemaLocation="TradeOrders.xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> + <xsd:import schemaLocation="TradeOrders.xsd2" namespace="http://trade.samples.websphere.ibm.com"/> + </xsd:schema> + </wsdl:types> + <wsdl:message name="OrderProcessorService_SubmitOrderTransactedQueue_InputMessage"> + <wsdl:part name="parameters" element="tns:SubmitOrderTransactedQueue"/> + </wsdl:message> + <wsdl:message name="OrderProcessorService_SubmitOrder_InputMessage"> + <wsdl:part name="parameters" element="tns:SubmitOrder"/> + </wsdl:message> + <wsdl:message name="OrderProcessorService_isOnline_InputMessage"> + <wsdl:part name="parameters" element="tns:isOnline"/> + </wsdl:message> + <wsdl:portType name="OrderProcessorService"> + <wsdl:operation name="SubmitOrderTransactedQueue"> + <wsdl:input wsaw:Action="SubmitOrder" message="tns:OrderProcessorService_SubmitOrderTransactedQueue_InputMessage"/> + </wsdl:operation> + <wsdl:operation name="SubmitOrder"> + <wsdl:input wsaw:Action="SubmitOrderOnePhase" message="tns:OrderProcessorService_SubmitOrder_InputMessage"/> + </wsdl:operation> + <wsdl:operation name="isOnline"> + <wsdl:input wsaw:Action="isOnline" message="tns:OrderProcessorService_isOnline_InputMessage"/> + </wsdl:operation> + </wsdl:portType> +</wsdl:definitions> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd0 URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd0?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd0 (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd0 Wed Feb 11 04:07:29 2009 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<xs:schema elementFormDefault="qualified" targetNamespace="http://Trade.TraderOrderHost" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://Trade.TraderOrderHost"> + <xs:import schemaLocation="TradeOrders.xsd2" namespace="http://trade.samples.websphere.ibm.com"/> + <xs:element name="SubmitOrderTransactedQueue"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="order" nillable="true" type="q1:OrderDataBean" xmlns:q1="http://trade.samples.websphere.ibm.com"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="SubmitOrder"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="order" nillable="true" type="q2:OrderDataBean" xmlns:q2="http://trade.samples.websphere.ibm.com"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="isOnline"> + <xs:complexType> + <xs:sequence/> + </xs:complexType> + </xs:element> +</xs:schema> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd1 URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd1?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd1 (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd1 Wed Feb 11 04:07:29 2009 @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/"> + <xs:element name="anyType" nillable="true" type="xs:anyType"/> + <xs:element name="anyURI" nillable="true" type="xs:anyURI"/> + <xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/> + <xs:element name="boolean" nillable="true" type="xs:boolean"/> + <xs:element name="byte" nillable="true" type="xs:byte"/> + <xs:element name="dateTime" nillable="true" type="xs:dateTime"/> + <xs:element name="decimal" nillable="true" type="xs:decimal"/> + <xs:element name="double" nillable="true" type="xs:double"/> + <xs:element name="float" nillable="true" type="xs:float"/> + <xs:element name="int" nillable="true" type="xs:int"/> + <xs:element name="long" nillable="true" type="xs:long"/> + <xs:element name="QName" nillable="true" type="xs:QName"/> + <xs:element name="short" nillable="true" type="xs:short"/> + <xs:element name="string" nillable="true" type="xs:string"/> + <xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/> + <xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/> + <xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/> + <xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/> + <xs:element name="char" nillable="true" type="tns:char"/> + <xs:simpleType name="char"> + <xs:restriction base="xs:int"/> + </xs:simpleType> + <xs:element name="duration" nillable="true" type="tns:duration"/> + <xs:simpleType name="duration"> + <xs:restriction base="xs:duration"> + <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/> + <xs:minInclusive value="-P10675199DT2H48M5.4775808S"/> + <xs:maxInclusive value="P10675199DT2H48M5.4775807S"/> + </xs:restriction> + </xs:simpleType> + <xs:element name="guid" nillable="true" type="tns:guid"/> + <xs:simpleType name="guid"> + <xs:restriction base="xs:string"> + <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/> + </xs:restriction> + </xs:simpleType> + <xs:attribute name="FactoryType" type="xs:QName"/> +</xs:schema> Added: incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd2 URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd2?rev=743209&view=auto ============================================================================== --- incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd2 (added) +++ incubator/stonehenge/trunk/stocktrader/php/order_processor/wsdl/TradeOrders.xsd2 Wed Feb 11 04:07:29 2009 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<xs:schema elementFormDefault="qualified" targetNamespace="http://trade.samples.websphere.ibm.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://trade.samples.websphere.ibm.com"> + <xs:complexType name="OrderDataBean"> + <xs:sequence> + <xs:element minOccurs="0" name="orderID" type="xs:int"/> + <xs:element minOccurs="0" name="orderType" nillable="true" type="xs:string"/> + <xs:element minOccurs="0" name="orderStatus" nillable="true" type="xs:string"/> + <xs:element minOccurs="0" name="openDate" type="xs:dateTime"/> + <xs:element minOccurs="0" name="completionDate" type="xs:dateTime"/> + <xs:element minOccurs="0" name="quantity" type="xs:double"/> + <xs:element minOccurs="0" name="price" type="xs:decimal"/> + <xs:element minOccurs="0" name="orderFee" type="xs:decimal"/> + <xs:element minOccurs="0" name="symbol" nillable="true" type="xs:string"/> + </xs:sequence> + </xs:complexType> + <xs:element name="OrderDataBean" nillable="true" type="tns:OrderDataBean"/> +</xs:schema>