-1

Looking for some help on how to complete the list operation. Code would be something like

client = Client(wsdl, plugins=[history, MyLoggingPlugin()])
client.service.list(?????,????)

Based on this excerpt from the python3 command: python –m zeep wsdl_file :

Global elements:
  ....    
  ns0:list(ns0:ListRequest)
  ....

Global types:
  xsd:anyType
  ....
  ns0:BaseFilter(isAscending: xsd:boolean, pageNumber: xsd:int, 
recordsPerPage: xsd:int, maxRecordsPerPage: xsd:int)
  ....
Operations:
   ....
   list(filter: ns0:BaseFilter) -> objectId: ns0:ObjectId[]
   ....

Digging into the documents I understand that ns0:BaseFilter is a complex element and I will need to use client.get_type. So with the following code I moved along and getting closer results.

myUserFilter = myBaseFilter(isAscending=True, pageNumber=0)
SendingXML = client.create_message(client.service, 'list', myUserFilter) `

Then the SendingXML looks like this:

   <ns0:list xmlns:ns0="http://www.strongmail.com/services/v2/schema">
      <ns0:filter>
        <ns0:isAscending>true</ns0:isAscending>
        <ns0:pageNumber>0</ns0:pageNumber>
      </ns0:filter>
    </ns0:list>
  </soap-env:Body>

I am not sure how to get the additional items on the filter element line/header. <ns0:filter> It should be the following (ns0 is missing as this is a sample)

<filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="UserFilter">
dbjock
  • 18
  • 4

1 Answers1

0

By lucky guess work, as I'm not fully understandning the vendors documentation and the WSDL, I found the solution to creating the correct xml.

The list operation is expecting the BaseFilter type as input, though if I use the UserFilter type instead it worked. Code changed as follows.

myBaseFilter = client.get_type('ns0:UserFilter') #Changed from ns0:BaseFilter
myUserListReq = myBaseFilter(isAscending=True, pageNumber=0, recordsPerPage=10,maxRecordsPerPage=200)
SendingXML = client.create_message(client.service, 'list', myUserListReq)

The SendingXML is now correct.

  <soap-env:Body>
    <ns0:list xmlns:ns0="http://www.strongmail.com/services/v2/schema">
      <ns0:filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:UserFilter">
        <ns0:isAscending>true</ns0:isAscending>
        <ns0:pageNumber>0</ns0:pageNumber>
        <ns0:recordsPerPage>10</ns0:recordsPerPage>
        <ns0:maxRecordsPerPage>200</ns0:maxRecordsPerPage>
      </ns0:filter>
    </ns0:list>
  </soap-env:Body>

Hopefully.. this may help someone in the future.

If anyone has any ideas on how I could have found that in the -m zeep WSDL_File output that would be a bonus, as I'm not sure what other things I will be running into.

dbjock
  • 18
  • 4