php_soap webservice demo下载

weixin_39820835 2019-09-10 05:00:15
php扩展 php_soap webservice服务端搭建demo

附件中包含所有文件,详细说明见readme
相关下载链接://download.csdn.net/download/leoflags/8149807?utm_source=bbsseo
...全文
10 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
Now everybody heard of Amazon.com. What not everybody knows that Amazon released an API to access its huge catalogs. What this basically means is that each developer can access the information from Amazon following some simple protocols and every site owner can enhance his own website with content and features from Amazon. The Amazon API comes as a simple Webservice. Here are the first Web services that they have exposed: - Product Display : The ability to search for and retrieve product information from the Amazon.com catalog. - Shopping Cart : The ability to add Amazon.com products to shopping carts, wish lists, and registries from third party locations. No matter of your intentions, you will first need to register and obtain a valid developer token. You can get your token here at this address: http://www.amazon.com/webservices The current listed implementation of Amazon webservices uses Keyword searches. It has basically the same results as searching the books catalog online. As any developer/webmaster can see in the "Amazon.com Web Services Developers Kit v 1.0" document, a lot of other Amazon features are exposed. This would imply extending the base structure I present here. There are multiple approaches from a developer's point of view. The simplest one deals with SOAP and web services classes already implemented in PHP. You could also extend the PEAR's XMLParser object to parse Amazon results. The reason I did not choose these directions is because they require additional extensions installed with PHP. What I currently use is the XML parsing package that comes embedded in PHP, so it is slightly more general. What basically happens in this implementation is that the search word entered by the used is embedded into a XML url that is then retrieved from Amazon.com. Then PHP builds a nice display for the information received. I should let the code talk for itself. Here is the main controller, with a small search form for Amazon: http://www.php9.com/php/source/amazon.phps As you see, the actual code is very small. Then here is the class used in the controller to parse the XML returned by Amazon. http://www.php9.com/php/source/amazon_class.phps Then the configuration file. I need to remember you that you need to change the DEVELOPER_TOKEN constant with the one you will obtain from Amazon. The current license key belongs to me. http://www.php9.com/php/source/amazon_config.phps And here is the layout template used to build the output from the XML document retrieved from Amazon. It is parsed every time a book record is retrieved, so the output rendering is the fastest possible. http://www.php9.com/php/source/amazon_layout.phps Here you have the full package zipped. http://www.php9.com/php/source/amazon.zip And of course a demo: http://www.php9.com/amazon.php Feel free to use it and improve. I am open to suggestions
实例: 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 = "\n\nCompany Info. <em>Webservice</em> client - Written by: Tim Akinbo\n\n"; $html .= "\n"; $html .= "\n\n"; $html .= "\n"; $html .= "\n\n\n\n
 Company Info
\n\n\n"; $html .= "\n\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 .= "\n\n\n"; $html .= "
Company NameStock SymbolPercentage Change
" . $results['company'] . "" . $results['symbol'] . "" . $results['changePercent'] . "
\n
\n\n"; echo $html; ?>

12,793

社区成员

发帖
与我相关
我的任务
社区描述
CSDN 下载资源悬赏专区
其他 技术论坛(原bbs)
社区管理员
  • 下载资源悬赏专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧