如何在 PHP 中使用 SOAP 服务


How do I use SOAP service in PHP?

我是 php 中的 SOAP 新手。SOAP 在我的 Apache 中启用。我有一个示例代码。代码包含行require_once('SOAP/Client.php'); 。运行文件时,我收到致命错误,例如Warning: require_once(SOAP/Client.php) [function.require-once]: failed to open stream:.我是否需要将 SOAP 包放在我的示例文件夹中。如果是,也会出现一些错误。我该如何处理这个问题。请指教。

下面是我的代码,

`<?php
// bind SOAP/Client.php -> path of the php file
require_once "SOAP/Client.php";
// URI delivered to web service
$sc = new SOAP_Client("http://domain/SOAP/Server.php");
// start call function to use the function of the Web Service
$parameter = array();
$result = $sc->call ("now", &$parameter, "urn:TimeSerivce");
// print result
print $result."'n";
?>`

提前谢谢。

我相信使用库SoapClient是可能的(必须启用SoapClient,请参阅phpinfo)。http://www.php.net/manual/en/class.soapclient.php

如果您尝试连接的服务器需要 CA 证书,那么唯一的方法是使用 cURL。http://www.php.net/manual/en/book.curl.php

干杯!