如何为WSDL创建一个数组并使用suds将其作为参数传递?

2024-05-19 21:56:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想提个要求。这些是必需的参数。问题是我不知道如何创建一个数组,我可以传递一个参数,以便使用suds库发出请求。你知道吗

$dogetitemsinfo_request = array(
   'sessionHandle' => '22eb99326c6be29aa16d07d622bcfbcbee94ad54846f2f4e03_1',
   'itemsIdArray' => array(975967833, 886978949),
);

这是我提出请求的课程:

class OffersViewAndOptions:
      @classmethod
            def doGetItemsInfo(
                    cls,
                    sessionHandle,
                    itemsIdArray,
            ):
                global client
                client = Client('https://webapi.allegro.pl/service.php?wsdl')
                response = client.service.doGetItemsInfo(
                    sessionHandle=sessionHandle,
                    itemsIdArray=itemsIdArray,
                )
                do_get_items_info = {
                    'itId': response.item[0].item[0].itId,
                }
                return do_get_items_info

这是我第一次尝试将数组作为参数传递

array = [6688519219, 6688519219]
getitem = OffersViewAndOptions.doGetItemsInfo(session_handle_part, array)

答案如下:

suds.WebFault: Server raised fault: 'Element '{https://webapi.allegro.pl/service.php}itemsIdArray': Character content other than whitespace is not allowed because the content type is 'element-only'.

第二,我搜索了可能的解决方案,我发现:

array = client.factory.create('array')
array.item = [7554257498, 6688519219]
request.option=array

答案如下:

suds.TypeNotFound: Type not found: 'array'

此文档可能有帮助: https://allegro.pl/webapi/documentation.php/show/id,1093


Tags: httpsclient参数serviceallegro数组itemarray