Skip to content

Zeep setting defined valuesas 'NotSet' #991

Open

Description

@elmorek

Hi, I am experience the following behavior:

def getDeviceDetail(client=None, auth=None, dbid=None): from lxml import etree component = dict({'type':'device', 'dbid':dbid}) print(component) node = client.create_message(client.service, 'detailQuery', auth=auth, component=component) print(etree.tostring(node, encoding="unicode", pretty_print=True)) r = client.service.detailQuery(auth=auth, component=component)

getDeviceDetail(client=client, auth=creds, dbid=1234)

The output is as follows:

print(component): {'type': 'device', 'dbid': 1234}
print(etree.tostring(node, encoding="unicode", pretty_print=True)):
(Skipping the rest of the output) <component type="NotSet" dbid="NotSet"/>

zeep version is 3.4.0
Any idea?

Activity

  1. ciscomonkey commented on Dec 9, 2019

    @ciscomonkey

    I'm having this same issue. Did you ever find out anything on this?
    <component type="NotSet" dbid="NotSet"/>

  2. ciscomonkey commented on Dec 9, 2019

    @ciscomonkey

    I did test this morning, and this works correctly using suds-community.

  3. hassam-theentertainerme commented on Dec 10, 2019

    @hassam-theentertainerme

    yes you need to override the transport.py
    I have overridden the method like

    `
    def post_xml(self, address, envelope, headers):
    """Post the envelope xml element to the given address with the headers.

        This method is intended to be overriden if you want to customize the
        serialization of the xml element. By default the body is formatted
        and encoded as utf-8. See ``zeep.wsdl.utils.etree_to_string``.
    
        """
        message = etree_to_string(envelope)
        if 'Radius="NotSet"' in message.decode('utf-8'):
            message = message.decode('utf-8').replace('Radius="NotSet"', 'Radius="10.00"')
            message = message.encode('utf-8')
        return self.post(address, message, headers)
    

    `

  4. ciscomonkey commented on Dec 10, 2019

    @ciscomonkey

    It appears that Zeep is not populating the values of the automatically converted object from the dictionary we are passing it.

    Using get_type:

    component_type = client.get_type('{http://www.nates.fr/API/1.0}COMPONENT_TYPE')
    component = component_type(type=tenant['type'], dbid=int(tenant['dbid']))

    Or factory:

    factory = client.type_factory('ns0')
    component = factory.COMPONENT_TYPE(type=tenant['type'], dbid=int(tenant['dbid']))

    Generates this XML:

    <component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="TENANT" dbid="XXX" xsi:type="ns0:COMPONENT_TYPE"/>

    Which results in the following error coming back from the API:

    org.xml.sax.SAXParseException; cvc-elt.4.3: Type 'ns0:COMPONENT_TYPE' is not validly derived from the type definition, 'null', of element 'component'.
    

    But passing in the dictionary instead, generates the correctly formatted XML that the API is expecting, it's just not populating the values as we would expect:

    <component type="NotSet" dbid="NotSet"/>
    
  5. llech commented on Nov 5, 2020

    @llech

    @ciscomonkey I've got similar issues, only that your solution doesn't work for me because my object is used as attribute, not as child tag...

  6. elmorek commented on Nov 5, 2020

    @elmorek
    Author

    hi @ciscomonkey. Did you figure out a solution for this or just used suds-community instead.

    Not sure if I get your comment above where you mentioned:

    But passing in the dictionary instead, generates the correctly formatted XML that the API is expecting, it's just not populating the values as we would expect:

    What do you mean? Can you provide an example?

    Thanks

  7. ciscomonkey commented on Dec 6, 2020

    @ciscomonkey

    @elmorek I just went with suds-community for this project.

  8. powo commented on Aug 4, 2023

    @powo

    I've been experiencing the same problem

    When passing a dict to a Operation (eg {"locale": "EN", "aNumber": "1234"}), it results in a Request with "NotSet":

    <Request locale="NotSet" aNumber="1234" />

    Here's en excerpt of the WSDL

      <xs:complexType name="getOrderDetails">
        <xs:sequence>
          <xs:element minOccurs="0" name="Request" type="tns:orderStateDetailReq"/>
        </xs:sequence>
      </xs:complexType>
      
      <xs:complexType name="orderStateDetailReq">
        <xs:complexContent>
          <xs:extension base="tns:frontendServiceParam">
            <xs:sequence/>
            <xs:attribute name="aNumber" type="xs:string"/>
            <xs:attribute name="pNumber" type="xs:string"/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      
      <xs:complexType abstract="true" name="frontendServiceParam">
        <xs:complexContent>
          <xs:extension base="tns:defaultServiceParam">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      
      <xs:complexType name="defaultServiceParam">
        <xs:complexContent>
          <xs:extension base="tns:localeHolder">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      
      <xs:complexType abstract="true" name="localeHolder">
        <xs:sequence/>
        <xs:attribute name="locale" type="tns:localeType" use="required"/>
      </xs:complexType>
      
      
        <xs:simpleType name="localeType">
        <xs:restriction base="xs:string">
          <xs:enumeration value="DE"/>
          <xs:enumeration value="EN"/>
        </xs:restriction>
      </xs:simpleType>
  9. highviolet commented on Nov 9, 2023

    @highviolet

    @powo Did you find a solution?

  10. ffmc-mayank commented on Jul 23, 2025

    @ffmc-mayank

    After spending quiet a bit of time trying to figure out why this may be happening, I noticed that it may have something to do with value being overwritten to NotSet in subsequent calls to render for scenarios where you have sequence in complexType and that is being extended by another complexType. After debugging through the code, I noticed that the render function is called twice for ComplexType that has sequence probably because of this.

    I added a return statement here and that seemed to have fixed the issue but I am unsure if this will have side affect on something else. This is my first time working with zeep so unsure if my conclusion from these observations are correct.

    @mvantellingen not sure if you are still maintaining this project but was curious to here your thoughts on whether this makes sense.

  11. added a commit that references this issue on Nov 26, 2025
    7176cfc
  12. swozny13 commented on Nov 26, 2025

    @swozny13

    We hit the same issue in our project. I’ve posted a fix in PR #1476.

    @ffmc-mayank could you check whether this fix also solves your issue? You commented on this thread quite recently, so you might still be interested.
    @mvantellingen could you take a look at this if you’re still actively involved in the project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions