pythonsoapzeep

String Type Doesn't Accept Collections as Value


I am receiving this error:

String Type Doesn't Accept Collections as Value

when I try to run this code snippet:

fetch_data = client.get_type('ns0:ArrayOfString')
    fetch = fetch_data ([
        "Unique_Key",
        "First_Name",
        "Last_Name",
        "Address1",
        "Address2",
        "City",
        "State",
        "Zip",
        "Source",
        "Grad_Year",
        "Email_Address",
        "Submission_Type",
        "Print_Response_Date",
        "Date_Fulfillment_Complete"])

Right above it I have this code section which works fine:

search_criteria = client.get_type('ns0:Ext_Webservice_ComplexType_SearchCriteria')
    search = search_criteria ([
        {
            "column_key": "Submission_Type",
            "operand": "<>",
            "value": "ELECTRONIC",
            "next": "and",
            "prefix": "",
            "suffix": ""
        },
        {
            "column_key": "Date_Fulfillment_Complete",
            "operand": "IS NULL",
            "value": "",
            "next": "",
            "prefix": "",
            "suffix": ""
        }
    ])

While I understand that they are using two different types, I am confused as to why one works and the other doesn't. I would think that an ArrayOfString would accept an array of strings but I probably am thinking about it incorrectly. Admittedly this is my first python project in a very long time (almost 8 years now) so I'm extremely rusty. Just kind of wondering where to go from here. The other answers haven't helped. I have tried adding the values as named parameters and have also tried to simply use the append function. I'm willing to bet the answer is probably obvious but I'm hoping some rubber ducking will help me figure this out.

Thanks in advance!

Edit: Running the mzeep command gives me back this:

ns0:ArrayOfExt_webservice_complextype_person(item:ns0:Ext_Webservice_ComplexType_Person[])

ns0:ArrayOfExt_webservice_complextype_recordwithkey(item:ns0:Ext_Webservice_ComplexType_RecordWithKey[])

ns0:ArrayOfExt_webservice_complextype_recordwithoutkey(item:ns0:Ext_Webservice_ComplexType_RecordWithoutKey[])

ns0:ArrayOfExt_webservice_complextype_searchcriteria(item:ns0:Ext_Webservice_ComplexType_SearchCriteria[])

ns0:ArrayOfInt(item: xsd:int[])

ns0:ArrayOfString(item: xsd:string[])

*Along with several others that I've removed for readability.

 

Solution

  • Based on that WSDL, this code works for me:

    from zeep import Client
    
    client = Client('https://ws.185red.com/wsdl/forms') 
    
    fetch_type = client.get_type('ns0:ArrayOfString')
    fetch = fetch_type([
        "Unique_Key",
        "First_Name",
        "Last_Name",
        "Address1",
        "Address2",
        "City",
        "State",
        "Zip",
        "Source",
        "Grad_Year",
        "Email_Address",
        "Submission_Type",
        "Print_Response_Date",
        "Date_Fulfillment_Complete"])
    
    criteria_type = client.get_type('ns0:ArrayOfExt_webservice_complextype_searchcriteria')
    criteria = criteria_type([
        {
            "column_key": "Submission_Type",
            "operand": "<>",
            "value": "ELECTRONIC",
            "next": "and",
            "prefix": "",
            "suffix": ""
        },
        {
            "column_key": "Date_Fulfillment_Complete",
            "operand": "IS NULL",
            "value": "",
            "next": "",
            "prefix": "",
            "suffix": ""
        }
    ])
    
    client.service.FetchData(0, criteria, fetch)
    

    I get back a "zeep.exceptions.Fault: Not Allowed. Message: Not logged in.", which makes sense, because I didn't authorize first and I'm just sending a message directly, but the call makes it to the service and it looks correctly formatted:

    <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
      <soap-env:Body>
        <ns0:FetchData xmlns:ns0="https://ws.185red.com">
          <formId>0</formId>
          <criteria>
            <item>
              <column_key>Submission_Type</column_key>
              <operand>&lt;&gt;</operand>
              <value>ELECTRONIC</value>
              <next>and</next>
              <prefix></prefix>
              <suffix></suffix>
            </item>
            <item>
              <column_key>Date_Fulfillment_Complete</column_key>
              <operand>IS NULL</operand>
              <value></value>
              <next></next>
              <prefix></prefix>
              <suffix></suffix>
            </item>
          </criteria>
          <keysToFetch>
            <item>Unique_Key</item>
            <item>First_Name</item>
            <item>Last_Name</item>
            <item>Address1</item>
            <item>Address2</item>
            <item>City</item>
            <item>State</item>
            <item>Zip</item>
            <item>Source</item>
            <item>Grad_Year</item>
            <item>Email_Address</item>
            <item>Submission_Type</item>
            <item>Print_Response_Date</item>
            <item>Date_Fulfillment_Complete</item>
          </keysToFetch>
        </ns0:FetchData>
      </soap-env:Body>
    </soap-env:Envelope>
    

    Can you try with my code?