Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Encoder/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct(
public readonly EncoderRegistry $registry,
public readonly Namespaces $namespaces,
public readonly BindingUse $bindingUse = BindingUse::LITERAL,
public readonly bool $skipXsiTypeDetection = false,
) {
}

Expand All @@ -28,6 +29,7 @@ public function withType(XsdType $type): self
$this->registry,
$this->namespaces,
$this->bindingUse,
$this->skipXsiTypeDetection,
);
}

Expand All @@ -39,6 +41,19 @@ public function withBindingUse(BindingUse $bindingUse): self
$this->registry,
$this->namespaces,
$bindingUse,
$this->skipXsiTypeDetection,
);
}

public function withSkipXsiTypeDetection(bool $skipXsiTypeDetection): self
{
return new self(
$this->type,
$this->metadata,
$this->registry,
$this->namespaces,
$this->bindingUse,
$skipXsiTypeDetection,
);
}
}
3 changes: 1 addition & 2 deletions src/Encoder/EncoderDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Soap\Encoding\Encoder;

use Soap\Engine\Metadata\Model\XsdType;
use Soap\WsdlReader\Model\Definitions\BindingUse;
use stdClass;
use WeakMap;

Expand Down Expand Up @@ -61,7 +60,7 @@ private function enhanceEncoder(Context $context, XmlEncoder $encoder): XmlEncod
$meta = $context->type->getMeta();
$isSimple = $meta->isSimple()->unwrapOr(false);

if (!$isSimple && !$encoder instanceof Feature\DisregardXsiInformation && $context->bindingUse === BindingUse::ENCODED) {
if (!$isSimple && !$encoder instanceof Feature\DisregardXsiInformation && !$context->skipXsiTypeDetection) {
$encoder = new XsiTypeEncoder($encoder);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Encoder/SimpleType/EncoderDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Soap\Encoding\Encoder\XmlEncoder;
use Soap\Encoding\Encoder\XsiTypeEncoder;
use Soap\Engine\Metadata\Model\XsdType;
use Soap\WsdlReader\Model\Definitions\BindingUse;
use function Psl\Iter\any;

final class EncoderDetector
Expand Down Expand Up @@ -56,7 +55,7 @@ private function enhanceEncoder(Context $context, XmlEncoder $encoder): XmlEncod
$encoder = new ElementEncoder($encoder);
}

if (!$encoder instanceof Feature\DisregardXsiInformation && $context->bindingUse === BindingUse::ENCODED) {
if (!$encoder instanceof Feature\DisregardXsiInformation && !$context->skipXsiTypeDetection) {
$encoder = new XsiTypeEncoder($encoder);
}

Expand Down
7 changes: 1 addition & 6 deletions src/TypeInference/XsiTypeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Soap\Encoding\Encoder\Context;
use Soap\Encoding\Encoder\FixedIsoEncoder;
use Soap\Engine\Metadata\Model\XsdType;
use Soap\WsdlReader\Model\Definitions\BindingUse;
use Soap\WsdlReader\Parser\Xml\QnameParser;
use Soap\Xml\Xmlns as SoapXmlns;
use VeeWee\Xml\Xmlns\Xmlns;
Expand Down Expand Up @@ -47,10 +46,6 @@ static function () use ($context, $value) {
*/
public static function detectXsdTypeFromXmlElement(Context $context, DOMElement $element): Option
{
if ($context->bindingUse !== BindingUse::ENCODED) {
return none();
}

$xsiType = $element->getAttributeNS(Xmlns::xsi()->value(), 'type');
if (!$xsiType) {
return none();
Expand Down Expand Up @@ -98,7 +93,7 @@ public static function detectEncoderFromXmlElement(Context $context, DOMElement
->withIsRepeatingElement(false);
$encoderDetectorContext = $context
->withType($type->withMeta(static fn () => $encoderDetectorTypeMeta))
->withBindingUse(BindingUse::LITERAL);
->withSkipXsiTypeDetection(true);

return some(
new FixedIsoEncoder(
Expand Down
Loading