python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Zeep dont handle restriction on simpleTypes?

Open 00cc00 opened this issue 8 years ago • 8 comments
trafficstars

  1. The version of zeep: 2.2.0 (python 2.7)
  2. The WSDL you are using
<xs:simpleType name="RollenEnum">
    <xs:restriction base="xs:string">
        <xs:enumeration value="VersichertePerson"/>
        <xs:enumeration value="Versicherungsnehmer"/>
        <xs:enumeration value="Beitragszahler"/>
        <xs:enumeration value="BezugsberechtigterImTodesfall"/>
        <xs:enumeration value="Ehepartner"/>
        <xs:enumeration value="GesetzlicherVertreter"/>
    </xs:restriction>
</xs:simpleType>

Hello there,

I'm only using the zeep library to parse WSDL files, so I don't use it as a real SOAP Client.

I need this to map it against own datamodels. However, I can't figure out if zeep handles restrictions in simpleTypes. The Type 'RollenEnum' is after parsing a 'String' BuiltinType. This is good in the first place. But I also need to map the restrictions like Enums and so on. Doesn't zeep support this or do I miss something?

I also tried to create Objects of this Type where I was able to input other Values than defined in the Enumeration.

Another example would be this:

<xs:simpleType name="someType">
    <xs:restriction base="xs:integer">
        <minInclusive value="0"/>
        <maxInclusive value="100"/>
    </xs:restriction>
</xs:simpleType>

Again, if I create a Type of 'someType' like so: someType(120) I don't get any Exception or something although the Value isn't valid like the Schema said.

So again my Question: Do I miss something or is this just not supported?

Thank you very much in advance for the help!

00cc00 avatar Jul 26 '17 15:07 00cc00

I've got the same problem. I need to be able to use restrictions to consume, validate and create WebServices.

The problem here seems to be, that the SchemaVisitor is reading the base of the restriction and returns and does not consume the children of the restriction tag. Here, handlers for the different restriction types need to be implemented.

Additionally, for creating WebServices, an API would be required to properly define such restrictions

hansingt avatar Jul 31 '17 11:07 hansingt

Yeah the data validation is still not really implemented properly. I've started adding some validation based on if something is required or not but thats it. It's something I want to focus on next (and can definitely use help on this)

mvantellingen avatar Aug 12 '17 07:08 mvantellingen

@mvantellingen To what extent could pre-existing XSD validation libraries be used to simplify the task of implementation here? I'm not familiar with any, just wondering out loud ;). Would be great if zeep could become capable of (close to) full XSD validation support combined with its already great type inspection.

bartkl avatar Jun 13 '18 09:06 bartkl

There are no xsd validation libraries for python. Originally I intended to rely on lxml for validation but that doesn’t support xsd schema linking at the wsdl level.

Validation shouldn’t be too hard, just haven’t given it priority

mvantellingen avatar Jun 13 '18 18:06 mvantellingen

+1 for this issue I am moving from suds to zeep as google has moved their googleads-python-lib to zeep from suds. I'm trying to get a enum type which works but has no attributes :-), so not much use I will need to use the suds client to handle enum types - not ideal having two soap clients hanging around. Cheers Sanjay

sanjayhallan avatar Jul 06 '18 07:07 sanjayhallan

@mvantellingen I have urgency on this matter. Kindly contact me so that we can work something out.

carlosmaguda avatar Aug 21 '18 21:08 carlosmaguda

I suppose there are no development in this feature no? So the temporal fix I suppose is to use other library? Someone has a recommendation? Even if it is in another language, because I think suds is worse than Zeep, and there isn't a better one than Zeep in Python

set92 avatar Apr 16 '19 12:04 set92

Hi! Is there any progress on this issue?

ManuelAngel99 avatar Mar 08 '23 12:03 ManuelAngel99