字符串类型不接受集合作为值

String Type Doesn't Accept Collections as Value

我收到此错误:

字符串类型不接受集合作为值

当我尝试 运行 这个代码片段时:

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"])

在它的正上方,我有这个代码部分可以正常工作:

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": ""
        }
    ])

虽然我知道他们使用的是两种不同的类型,但我很困惑为什么一种有效而另一种无效。我认为 ArrayOfString 会接受一个字符串数组,但我可能想错了。不可否认,这是我很长一段时间以来(现在将近 8 年)的第一个 python 项目,所以我非常生疏。只是想知道从这里去哪里。其他答案没有帮助。我曾尝试将值添加为命名参数,也曾尝试简单地使用 append 函数。我敢打赌答案可能很明显,但我希望一些橡皮鸭能帮助我解决这个问题。

提前致谢!

编辑:运行 mzeep 命令返回给我:

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.

 

基于该 WSDL,此代码适用于我:

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)

我得到一个“zeep.exceptions.Fault: Not Allowed. Message: Not logged in.”,这是有道理的,因为我没有先授权,我只是直接发送消息,但是调用使其进入服务并且它看起来格式正确:

<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>

你能试试我的代码吗?