热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

尝试使用zendsoap时找不到

我正在尝试使用zendframeworkzend-soap库在PHP中编写SOAP服务器。这是我的目录结构:

我正在尝试使用zendframework/zend-soap库在PHP中编写SOAP服务器。这是我的目录结构:

|- app/
|- mySoapService.php
|- composer.json
|- composer.lock
|- vendor/

这是composer.json的内容:

{
"name": "my_soap_service","description": "This package is implementing a SOAP service.","type": "project","require": {
"zendframework/zend-soap": "^2.8"
},"require-dev": {
}
}

我在终端中输入了以下命令:

zeinab: ~/my_soap_server$ composer install
PHP Warning: Module 'soap' already loaded in Unknown on line 0
PHP Warning: Module 'soap' already loaded in Unknown on line 0
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 10 installs,0 updates,0 removals
- Installing psr/container (1.0.0): Loading from cache
- Installing container-interop/container-interop (1.2.0): Loading from cache
- Installing zendframework/zend-stdlib (3.2.1): Loading from cache
- Installing zendframework/zend-validator (2.12.2): Downloading (100%)
- Installing zendframework/zend-escaper (2.6.1): Downloading (100%)
- Installing zendframework/zend-uri (2.7.1): Downloading (100%)
- Installing zendframework/zend-eventmanager (3.2.1): Loading from cache
- Installing zendframework/zend-code (3.4.1): Downloading (100%)
- Installing zendframework/zend-server (2.8.1): Downloading (100%)
- Installing zendframework/zend-soap (2.8.0): Downloading (100%)
zendframework/zend-validator suggests installing psr/http-message (psr/http-message,required when validating PSR-7 UploadedFileInterface instances via the Upload and UploadFile validators)
zendframework/zend-validator suggests installing zendframework/zend-db (Zend\Db component,required by the (No)RecordExists validator)
zendframework/zend-validator suggests installing zendframework/zend-filter (Zend\Filter component,required by the Digits validator)
zendframework/zend-validator suggests installing zendframework/zend-i18n (Zend\I18n component to allow translation of validation error messages)
zendframework/zend-validator suggests installing zendframework/zend-math (Zend\Math component,required by the Csrf validator)
zendframework/zend-validator suggests installing zendframework/zend-i18n-resources (Translations of validator messages)
zendframework/zend-validator suggests installing zendframework/zend-servicemanager (Zend\ServiceManager component to allow using the ValidatorPluginmanager and validator chains)
zendframework/zend-validator suggests installing zendframework/zend-session (Zend\Session component,^2.8; required by the Csrf validator)
zendframework/zend-code suggests installing doctrine/annotations (Doctrine\Common\Annotations >=1.0 for annotation features)
zendframework/zend-soap suggests installing zendframework/zend-http (Zend\Http component)
Package container-interop/container-interop is abandoned,you should avoid using it. Use psr/container instead.
Writing lock file
Generating autoload files

并且:

zeinab:~/my_soap_server$ composer require zendframework/zend-soap
PHP Warning: Module 'soap' already loaded in Unknown on line 0
PHP Warning: Module 'soap' already loaded in Unknown on line 0
Using version ^2.8 for zendframework/zend-soap
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package container-interop/container-interop is abandoned,you should avoid using it. Use psr/container instead.
Writing lock file
Generating autoload files

这是mySoapService.php的内容:

class MyClass {
/**
* @param integer $inputParam
* @return string
*/
public function method1($inputParam) {
return "This is your input: " . $inputParam . ".";
}
/**
* @param integer $inputParam1
* @param string $inputParam2
* @return float
*/
public function method2($inputParam1,$inputParam2) {
return "This is your inputs: " . $inputParam1 . " and " . $inputParam2 . ".";
}
}
$server = new Zend\Soap\Server(null,$options);
// Bind Class to Soap Server
$server->setClass('MyClass');
// Bind already initialized object to Soap Server
$server->setObject(new MyClass());
$server->handle();

但是当我尝试使用php mySoapService.php运行它时,出现此错误:

zeinab:~/my_soap_server$ php app/mySoapServer.php
PHP Warning: Module 'soap' already loaded in Unknown on line 0
PHP Fatal error: Uncaught Error: Class 'Zend\Soap\Server' not found in /home/zeinab/my_soap_server/app/mySoapServer.php:23
Stack trace:
#0 {main}
thrown in /home/zeinab/my_soap_server/app/mySoapServer.php on line 23

我还尝试将"zendframework/zend-soap": "^2.8"放在require的{​​{1}}和require-dev部分中,并重复该过程;发生了相同的结果。



似乎您忘记了添加作曲家的自动加载功能。告诉PHP在哪里可以找到要实例化的类是必要的。看看Composer's documentation,了解有关它的更多信息。

在文件的开头添加include __DIR__ . '/PATH/TO/VENDOR/FOLDER/autoload.php';


推荐阅读
  • 本文详细介绍了cisco路由器IOS损坏时的恢复方法,包括进入ROMMON模式、设置IP地址、子网掩码、默认网关以及使用TFTP服务器传输IOS文件的步骤。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了Redis的基础数据结构string的应用场景,并以面试的形式进行问答讲解,帮助读者更好地理解和应用Redis。同时,描述了一位面试者的心理状态和面试官的行为。 ... [详细]
  • 本文介绍了RPC框架Thrift的安装环境变量配置与第一个实例,讲解了RPC的概念以及如何解决跨语言、c++客户端、web服务端、远程调用等需求。Thrift开发方便上手快,性能和稳定性也不错,适合初学者学习和使用。 ... [详细]
  • 本文介绍了通过ABAP开发往外网发邮件的需求,并提供了配置和代码整理的资料。其中包括了配置SAP邮件服务器的步骤和ABAP写发送邮件代码的过程。通过RZ10配置参数和icm/server_port_1的设定,可以实现向Sap User和外部邮件发送邮件的功能。希望对需要的开发人员有帮助。摘要长度:184字。 ... [详细]
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • 本文介绍了在mac环境下使用nginx配置nodejs代理服务器的步骤,包括安装nginx、创建目录和文件、配置代理的域名和日志记录等。 ... [详细]
  • 如何查询zone下的表的信息
    本文介绍了如何通过TcaplusDB知识库查询zone下的表的信息。包括请求地址、GET请求参数说明、返回参数说明等内容。通过curl方法发起请求,并提供了请求示例。 ... [详细]
  • 基于Socket的多个客户端之间的聊天功能实现方法
    本文介绍了基于Socket的多个客户端之间实现聊天功能的方法,包括服务器端的实现和客户端的实现。服务器端通过每个用户的输出流向特定用户发送消息,而客户端通过输入流接收消息。同时,还介绍了相关的实体类和Socket的基本概念。 ... [详细]
  • centos安装Mysql的方法及步骤详解
    本文介绍了centos安装Mysql的两种方式:rpm方式和绿色方式安装,详细介绍了安装所需的软件包以及安装过程中的注意事项,包括检查是否安装成功的方法。通过本文,读者可以了解到在centos系统上如何正确安装Mysql。 ... [详细]
  • 1.WebServicea.定义:WebService是一种跨编程语言和跨操作系统平台的远程调用技术b.三大技术:XMLXSD,SOAP, ... [详细]
  • 那么多优秀的自动化测试工具,而你只知道Selenium?
    如今,作为一名软件测试工程师,几乎所有人都需要具备自动化测试相关的知识,并且懂得如何去利用工具,来为企业减少时间成本和错误成 ... [详细]
  • 分布式Dubbo 分布式服务
    分布式,du ... [详细]
author-avatar
土豆小妈姐_645
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有