Skip to content

Client is expecting MixedResult for some reason. #585

@Knappster

Description

@Knappster
Q A
Version 4.2.0

Summary

Fairly new to using SOAP, so I apologise upfront if I'm doing something stupid.

I'm attempting to utilise the this Capita payment portal API (WSDL: https://sbsctest.e-paycapita.com/scp/scpws/scpSimpleClient.wsdl).

When calling scpSimpleInvoke I'm expecting a ScpSimpleInvokeResponse response (as per their documentation), but the in the generated client it expects a MixedResult.

Similarly, with the scpSimpleQuerymethod I would expect to pass in a scpSimpleQueryRequest object but it's expecting a MultiArgumentRequest.

I hope it's something obvious I'm doing wrong and not a bug.

Config:

<?php

use Phpro\SoapClient\CodeGenerator\Assembler;
use Phpro\SoapClient\CodeGenerator\Rules;
use Phpro\SoapClient\CodeGenerator\Config\Config;
use Phpro\SoapClient\Soap\EngineOptions;
use Phpro\SoapClient\Soap\DefaultEngineFactory;

return Config::create()
    ->setEngine($engine = DefaultEngineFactory::create(
        EngineOptions::defaults('https://sbsctest.e-paycapita.com/scp/scpws/scpSimpleClient.wsdl')
    ))
    ->setTypeDestination('SoapClient/Capita/Types')
    ->setTypeNamespace('App\SoapClient\Capita\Types')
    ->setClientDestination('SoapClient/Capita')
    ->setClientName('CapitaClient')
    ->setClientNamespace('App\SoapClient\Capita')
    ->setClassMapDestination('SoapClient/Capita')
    ->setClassMapName('CapitaClassmap')
    ->setClassMapNamespace('App\SoapClient\Capita')
    ->addRule(new Rules\AssembleRule(new Assembler\GetterAssembler(new Assembler\GetterAssemblerOptions())))
    ->addRule(new Rules\AssembleRule(new Assembler\ImmutableSetterAssembler(
        new Assembler\ImmutableSetterAssemblerOptions()
    )))
    ->addRule(
        new Rules\IsRequestRule(
            $engine->getMetadata(),
            new Rules\MultiRule([
                new Rules\AssembleRule(new Assembler\RequestAssembler()),
                new Rules\AssembleRule(new Assembler\ConstructorAssembler(new Assembler\ConstructorAssemblerOptions())),
            ])
        )
    )
    ->addRule(
        new Rules\IsResultRule(
            $engine->getMetadata(),
            new Rules\MultiRule([
                new Rules\AssembleRule(new Assembler\ResultAssembler()),
            ])
        )
    )
    ->addRule(
        new Rules\IsExtendingTypeRule(
            $engine->getMetadata(),
            new Rules\AssembleRule(new Assembler\ExtendingTypeAssembler())
        )
    )
    ->addRule(
        new Rules\IsAbstractTypeRule(
            $engine->getMetadata(),
            new Rules\AssembleRule(new Assembler\AbstractClassAssembler())
        )
    )
;

Generated client:

<?php

namespace App\SoapClient\Capita;

use Phpro\SoapClient\Caller\Caller;
use Phpro\SoapClient\Type\MixedResult;
use App\SoapClient\Capita\Types;
use Phpro\SoapClient\Type\MultiArgumentRequest;
use Phpro\SoapClient\Type\ResultInterface;
use Phpro\SoapClient\Exception\SoapException;
use Phpro\SoapClient\Type\RequestInterface;

class CapitaClient
{
    /**
     * @var Caller
     */
    private $caller;

    public function __construct(\Phpro\SoapClient\Caller\Caller $caller)
    {
        $this->caller = $caller;
    }

    /**
     * @param RequestInterface & Types\ScpSimpleInvokeRequest $scpSimpleInvokeRequest
     * @return ResultInterface & MixedResult<mixed>
     * @throws SoapException
     */
    public function scpSimpleInvoke(\App\SoapClient\Capita\Types\ScpSimpleInvokeRequest $scpSimpleInvokeRequest) : \Phpro\SoapClient\Type\MixedResult
    {
        $response = ($this->caller)('scpSimpleInvoke', $scpSimpleInvokeRequest);

        \Psl\Type\instance_of(\Phpro\SoapClient\Type\MixedResult::class)->assert($response);
        \Psl\Type\instance_of(\Phpro\SoapClient\Type\ResultInterface::class)->assert($response);

        return $response;
    }

    /**
     * MultiArgumentRequest with following params:
     *
     * \App\SoapClient\Capita\Types\ScpSimpleQueryRequest $scpSimpleQueryRequest
     *
     * @param MultiArgumentRequest $multiArgumentRequest
     * @return ResultInterface & Types\ScpSimpleQueryResponse
     * @throws SoapException
     */
    public function scpSimpleQuery(\Phpro\SoapClient\Type\MultiArgumentRequest $multiArgumentRequest) : \App\SoapClient\Capita\Types\ScpSimpleQueryResponse
    {
        $response = ($this->caller)('scpSimpleQuery', $multiArgumentRequest);

        \Psl\Type\instance_of(\App\SoapClient\Capita\Types\ScpSimpleQueryResponse::class)->assert($response);
        \Psl\Type\instance_of(\Phpro\SoapClient\Type\ResultInterface::class)->assert($response);

        return $response;
    }

    /**
     * @param RequestInterface & Types\ScpVersionRequest $scpVersionRequest
     * @return ResultInterface & Types\ScpVersionResponse
     * @throws SoapException
     */
    public function scpVersion(\App\SoapClient\Capita\Types\ScpVersionRequest $scpVersionRequest) : \App\SoapClient\Capita\Types\ScpVersionResponse
    {
        $response = ($this->caller)('scpVersion', $scpVersionRequest);

        \Psl\Type\instance_of(\App\SoapClient\Capita\Types\ScpVersionResponse::class)->assert($response);
        \Psl\Type\instance_of(\Phpro\SoapClient\Type\ResultInterface::class)->assert($response);

        return $response;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions