PHPackages                             chenall/phalapi-soap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. chenall/phalapi-soap

ActiveLibrary[API Development](/categories/api)

chenall/phalapi-soap
====================

PhalApi 2.x 扩展类库：利用SOAP搭建Web Services

1.0.0(8y ago)3731[1 issues](https://github.com/chenall/phalapi-soap/issues)GPL-3.0+PHP

Since Apr 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/chenall/phalapi-soap)[ Packagist](https://packagist.org/packages/chenall/phalapi-soap)[ Docs](https://www.phalapi.net/)[ RSS](/packages/chenall-phalapi-soap/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

SOAP
----

[](#soap)

PhalApi SOAP扩展. 当需要使用SOAP时，需要在配置PHP时，通过`--enable-soap`参数开启SOAP。

### 安装

[](#安装)

在项目下直接运行以下命令即可完成扩展安装。

```
composer require chenall/phalapi-soap

```

### 配置

[](#配置)

需要将以下扩展配置添加到项目配置文件./Config/SOAP.php。

```
return array(
    /**
     * 扩展类库 - SOAP配置
     * @see SoapServer::__construct ( mixed $wsdl [, array $options ] )
     */
    'wsdl' => NULL,
    'options' => array(
        'uri' => 'http://localhost/soap.php',
        'port' => NULL,
    ),
);

```

其中，wsdl配置对应SoapServer构造函数的第一个参数，options配置则对应第二个参数，其中的uri须与下面的入口文件路径对应。

### SOAP服务端访问入口

[](#soap服务端访问入口)

SOAP扩展不需要注册DI服务，但需要单独实现访问入口，参考以下实现。

```
// $ vim ./Public/soap.php
/**
 * 统一访问入口
 */
require_once dirname(__FILE__) . '/init.php';

$di = \PhalApi\DI();
$server = new \PhalApi\SOAP\Lite();
$server->response();

```

至此，SOAP的服务端已搭建完毕。接下来，客户端便可通过SOAP进行访问了。

### SOAP客户端调用

[](#soap客户端调用)

SOAP客户端的使用，需要使用SoapClient类，其使用示例如下所示。

```
$url = 'http://api.phalapi.net/shop/soap.php';
$params = array('servcie' => 'Welcome.Say');

try {
    $client = new SoapClient(null,
        array(
            'location' => $url,
            'uri'      => $url,
        )
    );

    $data = $client->__soapCall('response', array(json_encode($params)));

    //处理返回的数据。。。
    var_dump($data);
}catch(SoapFault $fault){
    echo "Error: ".$fault->faultcode.", string: ".$fault->faultstring;
}

```

注意，客户端传递的接口参数，最后需要JSON编码后再传递。

### (5) SOAP调试脚本

[](#5-soap调试脚本)

SOAP扩展提供了一个可以发起SOAP访问的脚本，使用示例如下。

```
$ ./Library/SOAP/check.php http://api.phalapi.net/shop/soap.php "service=Welcome.Say"
array(3) {
  ["ret"]=>
  int(200)
  ["data"]=>
  string(11) "Hello World"
  ["msg"]=>
  string(0) ""
}

```

### (6) 对客户端的影响

[](#6-对客户端的影响)

当使用SOAP访问接口服务时，服务端可以通过使用SOAP扩展快速搭建Web Services，但对于客户端，如同使用PHPRPC协议一样，也要进行三方面的调整。这里简单说明一下。

- 调用方式的改变

首先是客户端调用方式的改变，需要通过SOAP协议进行访问。

- POST参数传递方式的改变

其次是对POST参数传递的改变。和前面的PHPRPC协议一样，客户端需要把全部的参数JSON编码后再传递。当POST的数据和GET的数据冲突时，以POST为准。

相应地，当需要传递POST参数时，客户需要这样调整：

```
$data = $client->__soapCall('response', array(json_encode($params)));

```

若无此POST参数，则可以忽略不传。

- 返回结果格式的改变

和PHPRPC协议一样，客户端接收到的是接口服务直接返回的源数据，不再是序列化后返回的字符串。如前面示例中，返回的是数组类型。

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2952d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8fa1dfbd8e196f3810c1e626ac3ec472490db7f59de668c0bbfa4ef2a8d71a7?d=identicon)[chenall](/maintainers/chenall)

---

Top Contributors

[![chenall](https://avatars.githubusercontent.com/u/628011?v=4)](https://github.com/chenall "chenall (2 commits)")

---

Tags

soapwsdlphalapiphalapi-soap

### Embed Badge

![Health badge](/badges/chenall-phalapi-soap/health.svg)

```
[![Health](https://phpackages.com/badges/chenall-phalapi-soap/health.svg)](https://phpackages.com/packages/chenall-phalapi-soap)
```

###  Alternatives

[laminas/laminas-soap

6121.8M37](/packages/laminas-laminas-soap)[camcima/camcima-soap-client

Wrapper around PHP SoapClient class

2672.0k2](/packages/camcima-camcima-soap-client)[conquer/services

Yii2 soap wsdl web services

1632.5k](/packages/conquer-services)[skautis/skautis

Library for API calls to SkautIS

1329.7k4](/packages/skautis-skautis)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
