soap-client icon indicating copy to clipboard operation
soap-client copied to clipboard

minOccurs=0 and return types

Open staabm opened this issue 3 years ago • 3 comments

Bug Report

Q A
BC Break no
Version 1.7.4

Summary

we use wsdls which define xsd:element .. type="xsd:string" tags including minOccurs=0, which makes these getters of this fields to return null at runtime.

<xsd:element minOccurs="0" maxOccurs="1" name="recId" type="xsd:string"/>

Current behavior

soap-client generates getters for these properties, with a regular @return string instead @return null|string

// ...
    /**
     * @return string
     */
    public function getGetRecIdFromKeyResult()
    {
        return $this->GetRecIdFromKeyResult;
    }
// ...

How to reproduce

generate a soap client for http://webconnector.tso.de/api/wsdl/SalesOrder.wsdl

Expected behavior

when minOccurs=0 the return-type should be nullable:

// ...
    /**
     * @return null|string
     */
    public function getGetRecIdFromKeyResult()
    {
        return $this->GetRecIdFromKeyResult;
    }
// ...

staabm avatar Jun 27 '22 10:06 staabm

Ext-soap does not provide that information. https://github.com/phpro/soap-client/blob/master/docs/known-issues/ext-soap.md#occurs

Currently, this issue can be avoided by not generating too strict types in the soap-client and optionally by using the IteratorAssembler.

This issue has been reported a few times: #346, #231, #282, #344, ...

Until we have a better way of getting the data back from the WSDL, there is no simple solution for this.

veewee avatar Jun 27 '22 10:06 veewee

thx for the response.

Currently, this issue can be avoided by not generating too strict types in the soap-client and optionally by using the IteratorAssembler.

this will only work for 1:n or m:n relationships between objects I guess, not for a scalar value like string?

This issue has been reported a few times: #346, #231, #282, #344, ...

Until we have a better way of getting the data back from the WSDL, there is no simple solution for this.

I see. I can now remember, that we talked about that already in the past :).

staabm avatar Jun 27 '22 11:06 staabm

this will only work for 1:n or m:n relationships between objects I guess, not for a scalar value like string?

Yes, that is only for multiple entries of the datatype. It could also work on scalars iirc. You might be able to test it on your service.

veewee avatar Jun 27 '22 11:06 veewee

Hello,

We noticed this issue got reported many times and want to tackle it at its core! Therefore, we've planned a project that will work on better types support. It’s going to be a huge project, so we are looking for ways to make development possible during our business hours instead of in our developers precious spare time.

In case you want this feature as badly as us: find out how you can support this project here 💚!

veewee avatar Oct 28 '22 07:10 veewee