-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect handling of union types #260
Comments
It's seems to me it's similar to #247, thus it can be hard to handle especially if it concerns the response object as PHP wouldn't be able to differentiate the two structs, this is why the generator creates only one class. In addition, it's based on the Structs returned by the SoapClient class so this is also the possible origin of the generated class. I can take a further look to it if you provide me the WSDL at [email protected]. |
I worked around this issue by making a callable function and using it like this: $setItems = function($items){
$this->Items = $items;
};
$setItems->call($reqA, $items); So that I can set the field directly and skip the setter (with its type check), and it works. We could have a 1 to many mapping between the item class and multiple representations (models) for its fields. As for sending the WSDL, I'm afraid I'd have to create a simplified and abstracted test case first... |
Or you disable the validation rules on the generation. In your case it's working because the property is an array of |
Not if the fields are only type hinted, or in other words of "mixed" type (and therefore not checked by PHP upon assignment). |
But if you pass to the SoapClient a derived model instance containing the typed properties, then it would generated a bad XML request because the derived modules would not be mapped correctly for the XML request, or I misunderstood what you're saying. Can you give an example? |
Possibly related to #268 |
Describe the bug
An incorrect package is generated when having 2 different requests with the same field name but different type.
This is the relevant WSDL snippet (redacted)
What happens is that a single
Items
class is generated for bothRequestA
andRequestB
, having a field of typestring[]
(probably the last type encountered in the WSDL).This makes it impossible to call
RequestA
due to the wrong type bindings.To Reproduce
Steps to reproduce the behavior:
Item[]
,string[]
expected)Expected behavior
Generate 2 different classes for the union type, one with a
string[]
field and another withItem[]
Additional context
Using wsdltophp/packagegenerator @ 5c8ee49
The text was updated successfully, but these errors were encountered: