Skip to content

DTO as SOAP objects #823

Closed Answered by Lumrenion
Lumrenion asked this question in Q&A
Discussion options

You must be logged in to vote

I foud a solution, no need for any magic with getters or setters. You can pass a typemap to the SoapClient to define from and to methods to handle type conversion between PHP and XML:

<?php
namespace Bka\AbsClient\Utility;

use Illuminate\Support\Carbon;

class XmlTypemap
{
    public static array $typemap = [
        [
        "type_ns"  => "http://www.w3.org/2001/XMLSchema",
        "type_name" => "dateTime",
        "from_xml"    => [self::class, 'fromXSDDateTime'],
        "to_xml" => [self::class, 'toXSDDateTime']
        ]
    ];

    public static function fromXSDDateTime(string $xml): \DateTimeInterface
    {
        $sxe = simplexml_load_string($xml);
        return new Carbon((s…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Lumrenion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant