mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 583 forks source link

Wsdl substitutionGroup not working #321

Open rahmonzoda opened 7 years ago

rahmonzoda commented 7 years ago

Hi Michael. Thank you for the excellent library. One question or it is a bug

I have wsdl file

           <!--  Some elements -->
            <!-- group-id and transmit-shipment are mutually exclusive -->
            <xsd:element name="groupIdOrTransmitShipment" abstract="true" />
            <xsd:element name="group-id" type="tns:GroupIDType" substitutionGroup="tns:groupIdOrTransmitShipment"/>
            <xsd:element name="transmit-shipment" type="xsd:boolean" fixed="true" substitutionGroup="tns:groupIdOrTransmitShipment"/>

            <xsd:complexType name="ShipmentType">
                <xsd:all>
                    <xsd:element ref="tns:groupIdOrTransmitShipment" />
                    <xsd:element name="shipping-point-id" type="tns:OutletIDType" minOccurs="0" />
                    <xsd:element name="expected-mailing-date" type="xsd:date" minOccurs="0"/>
                    <xsd:element name="provide-pricing-info" type="xsd:boolean" fixed="true" minOccurs="0"/>
                    <xsd:element name="provide-receipt-info" type="xsd:boolean" fixed="true" minOccurs="0"/>
                    <xsd:element name="delivery-spec" type="tns:DeliverySpecType"/>
                </xsd:all>
            </xsd:complexType>
           <!--  Some elements -->

My python code

client = zeep.Client('path to wsdl file')

# i try like here
shipmentType = client.wsdl.types.get_type('ns0:ShipmentType')

shipment = shipmentType(**{
  'group-id': '123456', # how to add 'group-id' ?
  'shipping-point-id': '12345',
  ...
})

zeep indicates an error: ShipmentType() got an unexpected keyword argument 'group_id'.

XSD Element Substitution http://www.w3schools.com/xml/schema_complex_subst.asp

mvantellingen commented 7 years ago

Oh thats not supported (yet). What were they thinking when they came up with that 'feature' :-)

arjenjb commented 7 years ago

If you are not already working on this issue, I'd like to volunteer and try to fix this problem.

mvantellingen commented 7 years ago

Thanks @arjenjb. Really appreciate the help. Let me know if you need any hints

ashleysommer commented 7 years ago

@arjenjb Did you start work on this or make any progress? I have urgent need of a python SOAP library that works out-of-the-box with substitutionGroups, if you have not started on this feature, I would like to implement it myself.

random343 commented 5 years ago

test.py.txt test.request.txt test.wsdl.txt

Hello @ashleysommer.

I have a similar problem like @rahmonzoda. I made changes from #433 to my zeep. But I still have the error "... got an unexpected keyword argument ...".

How can I correctly use your solution #433?

Files: test.wsdl.txt - My WSDL, test.py.txt - My code, test.request.txt - desired request.

tyler-proofserve-com commented 1 month ago

NIEM, an open US federal government standard, makes liberal use of SubstitutionGroups, eg with their DateRepresentation. This makes it effectively impossible to consume many government WSDLs with Zeep.