php-soap/wsdl 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-soap/wsdl

Composer 安装命令:

composer require php-soap/wsdl

包简介

Deals with WSDLs

README 文档

README

This package provides tools and helpers for dealing with WSDLs.

Want to help out? 💚

Want more information about the future of this project? Check out this list of the next big projects we'll be working on.

Installation

composer require php-soap/wsdl

WSDL Loader

A WSDL loader is able to load the contents of a WSDL file.

Psr18Loader

For loading WSDL's, you might want to use a PSR-18 client to do the hard HTTP work. You'll have to include the php-soap/psr18-transport in order to use this loader:

composer require php-soap/psr18-transport
use Http\Client\Common\PluginClient;
use Soap\Psr18Transport\Wsdl\Psr18Loader;

$loader = Psr18Loader::createForClient(
    $wsdlClient = new PluginClient(
        $psr18Client,
        ...$middleware
    )
);

$contents = $loader('http://some.wsdl');

StreamWrapperLoader

Loads the content of a WSDL by using any of the enabled stream wrappers. It can either be a file, http, ...

use Soap\Wsdl\Loader\StreamWrapperLoader;

$loader = new StreamWrapperLoader(
    stream_context_create([
        'http' => [
            'method' => 'GET',
            'header'=>"User-Agent: my loader\r\n",
        ],        
    ])
);
$contents = $loader($wsdl);

FlatteningLoader

This loader can be used if your WSDL file contains WSDL or XSD imports. It will any other loader internally to load all the parts. The result of this loader is a completely flattened WSDL file which you can e.g. cache on your local filesystem.

use Soap\Wsdl\Loader\FlatteningLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;

$loader = new FlatteningLoader(new StreamWrapperLoader());

$contents = $loader($wsdl);

CallbackLoader

This loader can be used if you want to have more control about how to load a WSDL. It can be used to decorate another loader, add debug statements, apply custom loading logic, ...

use Soap\Wsdl\Loader\CallbackLoader;

$loader = new CallbackLoader(static function (string $location) use ($loader, $style): string {
    $style->write('> Loading '.$location . '...');

    $result =  $loader($location);
    $style->writeln(' DONE!');

    return $result;
})

$contents = $loader($wsdl);

WSDL CLI Tools

wsdl-tools 1.0.0

Available commands:
  completion  Dump the shell completion script
  flatten     Flatten a remote or local WSDL file into 1 file that contains all includes.
  help        Display help for a command
  list        List commands
  validate    Run validations a (flattened) WSDL file.

Flattening

./bin/wsdl flatten 'https://your/?wsdl' out.wsdl

This command will download the provided WSDL location. If any imports are detected, it will download these as well. The final result is stored in a single WSDL file.

Validating

./bin/wsdl validate out.wsdl

This command performs some basic validations on the provided WSDL file. If your WSDL contains any imports, you'll have to flatten the WSDL into a single file first.

Extensions

By installing additional packages from php-soap, additional commands will be added to the WSDL tools:

  • wsdl-reader: Will install inspect commands that will give you a human-readable version of all information inside your WSDL.

Custom WSDL Loader

By default, all CLI tools use the StreamWrapperLoader. All CLI tools have a --loader=file.php option that can be used to apply a custom WSDL loader. This can be handy if your WSDL is located behind authentication or if you want to get control over the HTTP level.

Example custom PHP loader:

<?php

use Soap\Wsdl\Loader\StreamWrapperLoader;

return new StreamWrapperLoader(
    stream_context_create([
        'http' => [
            'method' => 'GET',
            'header'=> sprintf('Authorization: Basic %s', base64_encode('username:password')),
        ],        
    ])
);

WSDL Validators

This package contains some tools you can use to validate the format of WSDL files. It uses the power of veewee/xml DOM Validators internally.

SchemaSyntaxValidator

Validates all defined schemas and returns a list of all issues.

use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\Wsdl\Xml\Validator;
use VeeWee\Xml\Dom\Document;

$wsdl = Document::fromXmlString((new StreamWrapperLoader())($file));

echo "Validating Schemas".PHP_EOL;
$issues = $wsdl->validate(new Validator\SchemaSyntaxValidator());
echo ($issues->count() ? $issues->toString() : '🟢 ALL GOOD').PHP_EOL;

WsdlSyntaxValidator

Validates the WSDL file and returns a list of all issues.

use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\Wsdl\Xml\Validator;
use VeeWee\Xml\Dom\Document;

$wsdl = Document::fromXmlString((new StreamWrapperLoader())($file));

echo "Validating WSDL:".PHP_EOL;
$issues = $wsdl->validate(new Validator\WsdlSyntaxValidator());
echo ($issues->count() ? $issues->toString() : '🟢 ALL GOOD').PHP_EOL;

php-soap/wsdl 适用场景与选型建议

php-soap/wsdl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.97M 次下载、GitHub Stars 达 18, 最近一次更新时间为 2021 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 php-soap/wsdl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 php-soap/wsdl 我们能提供哪些服务?
定制开发 / 二次开发

基于 php-soap/wsdl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.97M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 32
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-07