【问题标题】:php web service example [closed]php web服务示例[关闭]
【发布时间】:2010-11-22 04:44:06
【问题描述】:

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

谢谢...

【问题讨论】:

    标签: php web-services


    【解决方案1】:

    【讨论】:

    • 其实我是这个领域的新手,我想了解更多关于webservice的信息。我们可以在没有 SOAP 或 RESTful Web 服务的情况下使用 Web 服务吗?如果我的问题是错误的,请原谅我..
    • 输入/输出数据格式与服务类型无关。如果您愿意,您甚至可以向请求的客户发送和接收纯文本。
    【解决方案2】:

    这就是你需要的。

    确保您已安装 Zend 框架 - 它说明了如果您没有安装它,无论如何如何安装它。

    它的好处是它允许发现 - 网络上的其余教程不是基本的 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();
    
    
    ?>
    

    谢谢, 波格丹

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

    【讨论】:

      【解决方案3】:

      这里有一个简单的例子,可以帮助您入门:

      https://stackoverflow.com/questions/502547/restful-webservice-to-sum-a-list-of-numbers

      还有一个稍微复杂一点的例子:

      Php webservice that takes JSON via POST and spits back an image

      【讨论】:

        【解决方案4】:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-10-08
          • 2016-01-29
          • 1970-01-01
          • 1970-01-01
          • 2012-09-11
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多