php php网络服务示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4242355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:23:44  来源:igfitidea点击:

php web service example

phpweb-services

提问by Miya

I am new to web services. I would like to get a good tutorial and example for web service using PHP. Please suggest to me some websites that explain these things in a simple way.

我是网络服务的新手。我想获得一个很好的教程和使用 PHP 的 Web 服务示例。请向我推荐一些以简单方式解释这些事情的网站。

Thank you...

谢谢...

回答by Bogdan Ciocoiu

This is what you need.

这就是你所需要的。

Make sure you habe Zend Framework installed - it says how to install it if you don't have it, anyway.

确保你已经安装了 Zend Framework - 无论如何,它会说明如果你没有它,如何安装它。

The good thing about it is that it allows Discovery - the rest of the tutorials on the net don't are basic POST/GET - no discovery of services.

关于它的好处是它允许发现 - 网络上的其余教程不是基本的 POST/GET - 没有服务发现。

<?php
ini_set('include_path', '/usr/share/php/libzend-framework-php/');
require_once 'Zend/Soap/AutoDiscover.php';
require_once "Zend/Soap/Server.php";

class BogdansInjectData {

 private $quotes = array(
    "one" => "answer one");  

  /**
   * @param string $quote
   * @return string
  */

  function PushData($quote) {
    /* just encase the string is in uppercase*/
    $symbol = strtolower($quote);
    /* if there is a quote for the day requested */
    if (isset($this->quotes[$quote])) {
      return $this->quotes[$quote];
    } else {
      /* else error */
      throw new SoapFault("Server","Unknown Symbol '$quote'.");
    }
  }
}

// if(isset($_GET['wsdl'])) {

$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('BogdansInjectData');
$autodiscover->handle();


?>

Thanks, Bogdan

谢谢,博格丹

PS: Follow this post as it's the source for the solution and it's constantly updated: http://www.getcomputerservices.co.uk/web-development/php-web-service-with-microsoft-discovery/

PS:请关注这篇文章,因为它是解决方案的来源,并且会不断更新:http: //www.getcomputerservices.co.uk/web-development/php-web-service-with-microsoft-discovery/

回答by dreeves