WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
425 stars 73 forks source link

Generating wrong field Type in StructClass #287

Open Poehli opened 1 year ago

Poehli commented 1 year ago

Describe the bug A struct may generate a wrong data type for fields, based on its defined name in the xsd File.

To Reproduce

  1. Download the official EID-WSDL from the German government (BSI Page or Direct download link)

  2. Use the generator to generate the structure types, with following command options:

    • --urlorpath="/Path/To/WSDL/TR-03130eID-Server.wsdl"
    • --destination="/PATH/TO/Soap/Generated"
    • --composer-name=""
    • --standalone=false
    • --namespace-directories=false
    • --src-dirname="/"
    • --namespace="Some\Php\Namespace"
    • --force
  3. Inspect StructType/PersonalDataType and compare with the xsd file

Expected behavior StructType/PersonalDataType should contain a field $DocumentType from type string|null, but got \Some\Php\Namespace\DocumentType with InlineXML fields and other unexpected fields.

Additonal Context Changing the name in the TR-03130eID-Server.xsd file from tns:DocumentType to tns:IdentityDocumentType created the expected string|null type

mikaelcom commented 1 year ago

Hi, The issue is that the oasis-dss-core-schema-v1.0-os.xsd defined a DocumentType with:

<xs:complexType name="DocumentType">
  <xs:complexContent>
    <xs:extension base="dss:DocumentBaseType">
      <xs:choice>
    <xs:element name="InlineXML" type="dss:InlineXMLType" />
    <xs:element name="Base64XML" type="xs:base64Binary" />
    <xs:element name="EscapedXML" type="xs:string" />
    <xs:element ref="dss:Base64Data" />
    <xs:element ref="dss:AttachmentReference" />
      </xs:choice>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

This declaration overrides the initial definition of the DocumentType from the TR-03130eID-Server.xsd such as:

<simpleType name="DocumentType">
  <restriction base="string">
    <pattern value="[A-Z ]{2}" />
  </restriction>
</simpleType>

As you managed to work around the issue, I think I won't be able to provider a better approach.

Let me know if you have an idea anyway.