nusoap php webservices 类
实例: <?php /* * Company Information * This script is a webservice client that consumes the webservice with * WSDL document at http://www.flash-db.com/services/ws/companyInfo.wsdl * * Given any stock symbol, it queries the webservice for information about * that stock symbol and it retrieves the results from the webservice * for display. * * A live demo of this program can be found at * http://timba.host.sk/companyinfo.php * * I actually noticed that NuSOAP doesn't have very good documentation * and I was thinking of writing one. I am working on my site at * http://timba.host.sk/ and when I am through with it, I would be putting * the documentation there. * * Written by: * Tim Akinbo * Department of Electronic and Electrical Engineering, * Obafemi Awolowo University, * Ile-Ife, Osun State, Nigeria * * Date: January 12, 2003: 23:10:10 GMT+0100 * */ // Include the NuSOAP soap toolkit file. include('nusoap.php'); // Create a SOAP Client object. $client = new soapclient("http://www.flash-db.com/services/ws/companyInfo.wsdl","wsdl"); // The following is a mechanism for capturing the stock symbol we want // to lookup. You can change this as required. $symbol = $_GET['symbol']; // Arguments for the webservice. $args = array ("username"=>"Any", "password"=>"Any", "ticker"=>$symbol); // Call the webservice "doCompanyInfo" method with the arguments. $results = $client->call("doCompanyInfo", $args); /* $results is an array with the following structure Array ( [symbol] => MU [company] => MICRON TECH [lastPrice] => 10.29 [tradedDate] => 1/10/2003 [tradedTime] => 4:01pm [change] => 0.34 [changePercent] => +3.42% [volumne] => 8895900 [averageVolume] => 9653090 [bid] => N/A [ask] => N/A [yesterdayClose] => 9.95 [open] => 10.04 [yearHigh] => 39.5 [yearLow] => 9.40 [dayLow] => 9.90 [dayHigh] => 10.38 [earnPerShare] => -1.59 [PE] => N/A [divDate] => 1-May-00 [yeild] => 0 [divShare] => N/A [marketCap] => 6.226B ) */ // We would now format the data for output in HTML. $html = "<html>\n<head>\n<title>Company Info. Webservice client - Written by: Tim Akinbo</title>\n</head>\n"; $html .= "<body>\n"; $html .= "<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"300\" bgcolor=\"#CCCCCC\">\n<tr>\n"; $html .= "<td><font face=\"Tahoma, Arial\" size=\"2\"> Company Info</font></td>\n"; $html .= "</tr>\n<tr>\n<td>\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\" bgcolor=\"#FFFFFF\">\n<tr>\n"; $html .= "<td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Company Name</strong></font></td><td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Stock Symbol</strong></font></td><td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Percentage Change</strong></font></td>\n</tr>\n"; $color = "#000000"; // $color is set to green if we have an appreciation in value ("+" present in $results['changePercent']) if (preg_match("/^\+/", $results['changePercent'])) $color = "#00CC33"; // else it is set to red if we have a depreciation ("-") if (preg_match("/^-/", $results['changePercent'])) $color = "#FF0000"; $html .= "<tr>\n<td><font face=\"Tahoma, Arial\" size=\"1\">" . $results['company'] . "</font></td><td><font face=\"Tahoma, Arial\" size=\"1\">" . $results['symbol'] . "</font></td><td><font face=\"Tahoma, Arial\" size=\"1\" color=\"$color\"><strong>" . $results['changePercent'] . "</strong></font></td>\n</tr>\n"; $html .= "</table>\n</td>\n</tr>\n</table>\n</body>\n</html>"; echo $html; ?>
- 粉丝: 0
- 资源: 1
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
- 1
- 2
前往页