承接 php-soap/wsdl-reader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

php-soap/wsdl-reader

Composer 安装命令:

composer require php-soap/wsdl-reader

包简介

A WSDL reader in PHP

README 文档

README

This package provides tools for reading WSDL files and to converting them to metadata that will be used in other parts of the php-soap packages.

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-reader

Example usage

use Soap\Engine\Metadata\Model\Method;
use Soap\Engine\Metadata\Model\Type;
use Soap\Wsdl\Loader\FlatteningLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\WsdlReader\Formatter\ShortMethodFormatter;
use Soap\WsdlReader\Formatter\ShortTypeFormatter;
use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
use Soap\WsdlReader\Wsdl1Reader;

// Reading WSDL
$loader = new FlatteningLoader(new StreamWrapperLoader());
$wsdl = (new Wsdl1Reader($loader))($wsdlLocation);

// Parsing metadata
$metadataProvider = new Wsdl1MetadataProvider($wsdl);
$metadata = $metadataProvider->getMetadata();

// Processing collected info:
var_dump($metadata->getMethods(), $metadata->getTypes());

As shown above, parsing the WSDL is done in phases:

  • Select any loader to load the content of the WSDL. Tip: make sure to flatten it!
  • Reading raw WSDL XML into value objects and XSD schema.
  • Converting this WSDL to usable metadata

This gives you the flexibility in all different layers:

  • You can specify how a WSDL will be loaded.
  • You can use the WSDL classes of this package to run your own data lookups/manipulations.
  • You can use the provided metadata to run your own data lookups/manipulations.
  • ...

Readers

This package provides some configurable WSDL readers. This gives you some flexibility in what version of WSDL is being parsed, what SOAP version you want to use, ...

WSDL1 and 1.1

WSDL 1 schema

use Soap\WsdlReader\Locator\ServiceSelectionCriteria;
use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
use Soap\WsdlReader\Model\Definitions\SoapVersion;
use Soap\WsdlReader\Wsdl1Reader;

$wsdl = (new Wsdl1Reader($loader))($wsdlLocation);

$criteria = ServiceSelectionCriteria::defaults()
    ->withPreferredSoapVersion(SoapVersion::SOAP_12);

$metadataProvider = new Wsdl1MetadataProvider($wsdl, $criteria);

The WSDL1Reader accepts a ParserContext. You don't have to configure it since it falls back to defaults. But if you want to configure things like known XSD schema locations, that would be the place to go!

Once the WSDL1 file has been read, it will try to find a SOAP 1.2 service from your WSDL file. This service will be converted into metadata you, as a human, can understand.

You can apply additional service selection criteria that will be used to find the SOAP service you prefer. By default,

  • The selection criteria allows any SOAP service. You can disable e.g. the HTTP-based SOAP services.
  • No SOAP version is preferred. The first SOAP service the system detects, will be selected. But you can specify a specific soap version as well.
  • You can specify a specific service name. If you don't, the first service will be selected.
  • You can specify a specific port name. If you don't, the first port will be selected.

WSDL2

WSDL 2 schema

Not implemented yet!

Console

This package extends the WSDL CLI Tools that are provided by the WSDL package. It provides these additional commands:

$ ./vendor/bin/wsdl

Available commands:
  inspect         Inspects WSDL file.
  inspect:method  Inspects a method of a WSDL file.
  inspect:type    Inspects types from WSDL file.
  inspect:ui      Inspects WSDL file through a user interface.  

Listing all contents

./vendor/bin/wsdl inspect your.wsdl

Method details

./vendor/bin/wsdl inspect:method your.wsdl SomeMethodName

Type details

./vendor/bin/wsdl inspect:type your.wsdl SomeType

UI

Sometimes, you want to inspect multiple types and methods at once. This package provides a TUI that allows you to inspect all types and methods in a WSDL file through a single command:

./vendor/bin/wsdl inspect:ui 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\FlatteningLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 21
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-23