Closed h4kuna closed 8 months ago
Thanks for reporting! It's nice to get some real-world feedback from you, pointing out some of the pitfalls of the new wsdl-based type system.
This seems to be a bug in the new WSDL reader package: https://github.com/php-soap/wsdl-reader/issues/19
I'll try to get to it soon.
@h4kuna
Can you retry with the latest version of wsdl-reader? https://github.com/php-soap/wsdl-reader/releases/tag/0.8.0
It should now generate code following the structure below.
The -
dash separation is still not supported by the encoder, so that will still remain an issue 'til we figure out a way to do encoding from our end (instead of inside PHP's SoapClient)
immobile
========
> http://www.immobinet.it/schema/WebserviceImmobileBundle:immobile {
categoria $categoria
citta $citta
?string $indirizzo
?string $numero
?string $zona
?geo-coordinates $coords
?ArrayOfDescrizione $descrizione
?ArrayOfAllegato $allegati
?immobile-abitabile $composizione
?immobile-appartamento $appartamento
?immobile-superficie $superficie
?immobile-terreno $terreno
?immobile-casa $casa
?immobile-villa $villa
?immobile-capannone $capannone
?immobile-ace $ace
?ArrayOfAttributo $attributi
?tipo-cucina $cucina
?string $giardino
?string $parcheggio
?string $riscaldamento
?string $box-auto
?string $posto-auto
?string $impianto-tv
?immobile-turistico $immobile-turistico
?ArrayOfDistanzaPoi $distanze
?codice-identificativo $codice-identificativo
?ArrayOfInformazioniExtra $informazioni-extra
@?string $id
@?int $id-agenzia
}
The generated classes looks like better. Could you set up nullable property by default null
value, because property is defined like
private ?\App\ChannelManager\ImmobiNet\Soap\Agenzia\Type\ImmobileVilla $villa;
but API return nothing and i get exception with
Typed property App\ChannelManager\ImmobiNet\Soap\Agenzia\Type\Immobile::$villa must not be accessed before initialization.
I haven't a choice, how check property before access.
I image like
private ?\App\ChannelManager\ImmobiNet\Soap\Agenzia\Type\ImmobileVilla $villa = null;
Yes, that's possible:
$assembler = new PropertyAssembler(
PropertyAssemblerOptions::create()->withOptionalValue()
);
Note: You probably want to combine this with the optional getter as well for type-safety:
$assembler = new GetterAssembler(GetterAssemblerOptions::create()->withOptionalValue());
Thank you, very much, it works.
I think, this behavior could be enabled by default.
No prob :)
I think, this behavior could be enabled by default.
I've considered it when implementing and don't think this is a good idea for several reasons:
This library follows the provided schema in the WSDL, so if it says it's a string
we shouldn't annotate it as string|null
cause that's confusing and not correct in every generated code scenario.
For example: it could make sense for wither-based requests but not for constructor based requests. Also for models that are being used as response DTOs it would be incorrect.
Instead, I've given to option for you to generate the code in the way you want. Just not by default.
@veewee
Hi, a related question:
when i make a request and try to parse the response (let's say BaseReturnType
) - it contains all the necessary property values set (dump shows them as expected). But when trying to access any of them via getters i get ... must not be accessed before initialization
.
How can i fix this ? i'm guessing it's because there's no constructor and thus it's hydrated using reflection (or the cloning breaks it?).
Setting the properties as nullable or giving default values makes no sense - as you said, if the schema says it's a string then it should be a string.
The case you mention should just work. Maybe best to open up a new issue and provide it with some more details so that I can take a look at it.
Bug Report
Summary
Hello, I use WSDL. I try to call method getImmobili. Where is
getImmobiliResponse->immobili->immobile
described. The gerated class looks like:And returned object looks like
The result is, I can't access to properties. The previous version 2.4.2 was generate all methods and has bug with property name #477.
Generated class with version 2.4.2