0

我在 php 中有一个示例代码:

$conditions = Array(
    "status_id" => "1"    
);
$params = Array(
    "method" => "call",
    "params" => Array($session, "order.list.filter", 
            Array($conditions, "order_id", 10) 
        )

而且我找不到如何将它翻译成python。

我有代码:

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://decorations.pl/webapi/soap/')
doctor = ImportDoctor(imp) 
url = 'http://decorations.pl/webapi/soap/?wsdl'
print url
client = Client(url, doctor=doctor)
print client

这给了我:

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913
Service ( Webapi_Soap_ApiService ) tns="http://decorations.pl/webapi/soap/"
  Prefixes (1)
   ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
  Ports (1):
   (Webapi_Soap_ApiPort)
     Methods (11):
        aquireApplicationLock(xs:string session, xs:string message, xs:boolean stealLock, )
        call(xs:string session, xs:string function, xs:anyType arguments, )
        checkApplicationLock(xs:string session, )
        checkObjectListModificationTime(xs:string session, xs:int objectType, ns0:Array list, )
        checkObjectLock(xs:string session, xs:int objectType, xs:int id, )
        checkObjectModificationTime(xs:string session, xs:int objectType, xs:int id, )
        getApplicationLock(xs:string session, )
        login(xs:string login, xs:string password, )
        logout(xs:string session, )
        releaseApplicationLock(xs:string session, xs:boolean stealLock, )
        updateApplicationLock(xs:string session, xs:boolean stealLock, )
     Types (48):
        ns0:Array
        ns0:ENTITIES
        ns0:ENTITY
        ns0:ID
        ns0:IDREF
        ns0:IDREFS
        ns0:NCName
        ns0:NMTOKEN
        ns0:NMTOKENS
        ns0:NOTATION
        ns0:Name
        ns0:QName
        ns0:Struct
        ns0:anyURI
        ns0:arrayCoordinate
        ns0:base64
        ns0:base64Binary
        ns0:boolean
        ns0:byte
        ns0:date
        ns0:dateTime
        ns0:decimal
        ns0:double
        ns0:duration
        ns0:float
        ns0:gDay
        ns0:gMonth
        ns0:gMonthDay
        ns0:gYear
        ns0:gYearMonth
        ns0:hexBinary
        ns0:int
        ns0:integer
        ns0:language
        ns0:long
        ns0:negativeInteger
        ns0:nonNegativeInteger
        ns0:nonPositiveInteger
        ns0:normalizedString
        ns0:positiveInteger
        ns0:short
        ns0:string
        ns0:time
        ns0:token
        ns0:unsignedByte
        ns0:unsignedInt
        ns0:unsignedLong
        ns0:unsignedShort

而且我不知道如何建立工作调用......我有调用'order.list.filter'的功能:

# after login...
conditions = ""
params = client.factory.create('ns0:Array')
params.Array = [ conditions , "order_id", 10]
lista = client.service.call(sesId, 'order.list.filter', parametry)
print lista

给我:

[1, 9, 10, 11, 12, 13, 14, 15, 16, 17]

但我无法建立像 php 那样给我结果的条件。我尝试使用 'ns0:Struct' 找到一些示例,但我无法编写代码,但它并没有以:

File ".\test.py", line 143, in <module>
  lista = client.service.call(sesId, 'order.list.filter', parametry)
File "build\bdist.win32\egg\suds\client.py", line 542, in __call__
File "build\bdist.win32\egg\suds\client.py", line 602, in invoke
File "build\bdist.win32\egg\suds\client.py", line 649, in send
File "build\bdist.win32\egg\suds\client.py", line 702, in failed
File "build\bdist.win32\egg\suds\bindings\binding.py", line 265, in get_fault
suds.WebFault: Server raised fault: 'Unknown error'
4

1 回答 1

0

我将在这里冒险并假设该$conditions变量的 python 等效项是:

conditions = {'status_id': 1}

因为我不知道其他变量是什么,所以我真的不知道如何构造$params.

于 2012-07-19T09:28:41.700 回答