pythonxsdzeepxsi

Python zeep xsi:type="xsd:string"


I'm trying to make a correct document, but it's not working. I need to wrap "value" in xsi:type="xsd:string"tag

plz tell me how to do this) Thank you

...
from zeep import Client, Transport

...
# it's work

    def add_temp_person_identifier(self,
                                   person_session_id=None,
                                   person_id=None,
                                   access_group_id=None):
        if person_session_id is None:
            person_session_id = self.open_person_editing_session(person_id=person_id)['value']

        namespace = ''

        for key, value in self.client.namespaces.items():
            if value == "http://localsite.com/IntergationService":
                namespace = key
        IdentifierType = self.client.get_type(f"{namespace}:IdentifierTemp")

        Identifier = IdentifierType(CODE='0000',
                                    IS_PRIMARY=False,
                                    PERSON_ID=person_id,)
        result = self.client.service.AddPersonIdentifier(person_session_id, Identifier)
        self.close_person_editing_session(person_session_id)
        return result


# need help with it. "value" must be in xsi:type="xsd:string" tag

    def find_by_login(self, login):
        return self.client.service.PersonSearch(self.session_id,
                                                fieldID='0de358e0',
                                                relation=0,
                                                value=login)

I googled + read the instructions but I don’t have the slightest idea how to follow it correctly.


Solution

  • context:

    I needed to generate request like this:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <PersonSearch xmlns="http://localsite/yyyyyy">
    .....
    <value xsi:type="xsd:string">xxxxxxx</value>
    </PersonSearch>
    </soap:Body>
    </soap:Envelope>`
    
    

    As can be seen from the example, the API expects the contents of the tag to be specified explicitly. For this you must have a parameter specified, such as a field. xsd.AnyObject(xsd.String(), login) - assigns a "string" data type parameter, taking it from a generic library object.

    from zeep import Client, Transport, xsd
    
    def find_by_login(self, login):
        return self.client.service.PersonSearch(self.session_id,
                                                fieldID='43a278d1',
                                                relation=0,
                                                value=xsd.AnyObject(xsd.String(), login))