定制 php-soap/xml 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

php-soap/xml

Composer 安装命令:

composer require php-soap/xml

包简介

XML wrappers for SOAP

README 文档

README

This package provides some tools on top of veewee/xml's DOM component in order to make it easier to deal with SOAP XML structures.

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/xml

Builder

SoapHeaders

Makes it possible to build the content of a soap:Header element.

use Soap\Xml\Builder\SoapHeaders;
use Soap\Xml\Builder\SoapHeader;
use Soap\Xml\Builder\Header\Actor;
use Soap\Xml\Builder\Header\MustUnderstand;
use Soap\Xml\Manipulator\PrependSoapHeaders;
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Builder\namespaced_element;
use function VeeWee\Xml\Dom\Builder\element;
use function VeeWee\Xml\Dom\Builder\value;

$doc = Document::fromXmlString($xml);
$builder = new SoapHeaders(
    new SoapHeader(
        $targetNamespace,
        'Auth',
        children(
            namespaced_element($targetNamespace, 'user', value('josbos')),
            namespaced_element($targetNamespace, 'password', value('topsecret'))
        ),
        // Optionally, you can provide additional configurators for setting
        // SOAP-ENV specific attributes:
        Actor::next(),
        new MustUnderstand()
    ),
    $header2,
    $header3
);

$headers = $doc->build($builder);

// You can prepend the soap:Header as first element of the soap:envelope
// Like this
$doc->manipulate(new PrependSoapHeaders(...$headers));

Note: The SoapHeader(s) can be configured by using any DOM builder configurator.

Locator

BodyNamespaceLocator

Locates the namespace of the first element inside the soap:Body.

use Soap\Xml\Locator\BodyNamespaceLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyNamespace = $doc->locate(new BodyNamespaceLocator());

SoapBodyLocator

Locates the soap:Body element inside a soap:Envelope

use Soap\Xml\Locator\SoapBodyLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyElement = $doc->locate(new SoapBodyLocator());

SoapEnvelopeLocator

Locates the soap:Envelope inside XML.

use Soap\Xml\Locator\SoapEnvelopeLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyElement = $doc->locate(new SoapEnvelopeLocator());

SoapHeaderLocator

Locates the soap:Header element inside a soap:Envelope

use Soap\Xml\Locator\SoapHeaderLocator;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$bodyElement = $doc->locate(new SoapHeaderLocator());

Manipulator

PrependSoapHeaders

See SoapHeaders builder:

$doc = Document::fromXmlString($xml);
$doc->manipulate(new PrependSoapHeaders($soapHeader));

XPath

EnvelopePreset

This preset allows you to use following xpath prefixes:

  • application: The namespace of the SOAP implementation.
  • soap: The soap prefix allows you to fetch common elements like Body, header, Envelope, ...
use Soap\Xml\Xpath\EnvelopePreset;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$xpath = $doc->xpath(new EnvelopePreset($doc));

$xpath->querySingle('/soap:Envelope');
$xpath->querySingle('//soap:Body');
$xpath->querySingle('//soap:Header');
$xpath->querySingle('//soap:Body//application:Foo');

WsdlPreset

This preset allows you to use following xpath prefixes:

  • wsdl: The wsdl prefix allows you to fetch common elements like definitions, types, services, operations, ...
use Soap\Xml\Xpath\WsdlPreset;
use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlString($xml);
$xpath = $doc->xpath(new WsdlPreset($doc));

$xpath->querySingle('/wsdl:definitions');
$xpath->querySingle('//wsdl:types');
$xpath->querySingle('//wsdl:services');

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.94M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 8
  • 依赖项目数: 10
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

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