Python泡沫没有';在调用中不包含参数

Python泡沫没有';在调用中不包含参数,python,parameter-passing,suds,Python,Parameter Passing,Suds,我不熟悉Python和肥皂水。使用SOAP UI,对我的服务的调用如下所示: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="<URL to service>" xmlns:ns1="<URL to second namespace>"> <soapenv:Header/> <s

我不熟悉Python和肥皂水。使用SOAP UI,对我的服务的调用如下所示:

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns="<URL to service>" 
    xmlns:ns1="<URL to second namespace>">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:AuthenticateCaller>
         <!--Optional:-->
         <ns:request>
            <ns1:LoanAccountNumber>292206816</ns1:LoanAccountNumber>
         </ns:request>
      </ns:AuthenticateCaller>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:ns0="<URL to service>" 
    xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:AuthenticateCaller/>
   </ns1:Body>
</SOAP-ENV:Envelope>
Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( YourService_cmV6YW9ubGluZS5uZXQ= )  tns="http://www.yourservice.com/soap/YourService_cmV6YW9ubGluZS5uZXQ="
   Prefixes (1)
  ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
   Ports (1):
  (YourService_cmV6YW9ubGluZS5uZXQ=Port)
     Methods (2):
        your_method(xs:string _your_param)
     Types (48):
        ns0:Array
        ns0:ENTITIES
        ns0:ENTITY
        ns0:ID
        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:hexBinary
        ns0:int
        ns0:integer
        ns0:language
        ns0:long
        ns0:negativeInteger
        ns0:positiveInteger
        ns0:short
        ns0:string
        ns0:time
        ns0:token

292206816
我使用肥皂水尝试了以下方法:

from suds.xsd.doctor import ImportDoctor, Import
imp = Import(<URL to service>)
imp.filter.add(<URL to second namespace>)
doctor = ImportDoctor(imp)
client = Client(url, doctor=doctor)
client.service.AuthenticateCaller(LoanAccountNumber='292206816')
从suds.xsd.doctor导入导入导入
imp=Import()
imp.filter.add()
医生=进口医生(imp)
客户端=客户端(url,医生=医生)
client.service.AuthenticateCaller(LoanAccountNumber='292206816')
生成的XML如下所示:

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns="<URL to service>" 
    xmlns:ns1="<URL to second namespace>">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:AuthenticateCaller>
         <!--Optional:-->
         <ns:request>
            <ns1:LoanAccountNumber>292206816</ns1:LoanAccountNumber>
         </ns:request>
      </ns:AuthenticateCaller>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:ns0="<URL to service>" 
    xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:AuthenticateCaller/>
   </ns1:Body>
</SOAP-ENV:Envelope>
Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( YourService_cmV6YW9ubGluZS5uZXQ= )  tns="http://www.yourservice.com/soap/YourService_cmV6YW9ubGluZS5uZXQ="
   Prefixes (1)
  ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
   Ports (1):
  (YourService_cmV6YW9ubGluZS5uZXQ=Port)
     Methods (2):
        your_method(xs:string _your_param)
     Types (48):
        ns0:Array
        ns0:ENTITIES
        ns0:ENTITY
        ns0:ID
        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:hexBinary
        ns0:int
        ns0:integer
        ns0:language
        ns0:long
        ns0:negativeInteger
        ns0:positiveInteger
        ns0:short
        ns0:string
        ns0:time
        ns0:token

调用中缺少LoanAccountNumber参数,该参数是API的键。它还缺少第二个名称空间,我认为ImportDoctor应该修复这个名称空间


我的问题是,LoanaCountNumber没有包含在API调用中,我遗漏了什么。

以下说明似乎可以帮助您:

首先,您必须打印
客户端
即时,这是代码中的
客户端
,因此您会看到如下内容:

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns="<URL to service>" 
    xmlns:ns1="<URL to second namespace>">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:AuthenticateCaller>
         <!--Optional:-->
         <ns:request>
            <ns1:LoanAccountNumber>292206816</ns1:LoanAccountNumber>
         </ns:request>
      </ns:AuthenticateCaller>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:ns0="<URL to service>" 
    xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:AuthenticateCaller/>
   </ns1:Body>
</SOAP-ENV:Envelope>
Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( YourService_cmV6YW9ubGluZS5uZXQ= )  tns="http://www.yourservice.com/soap/YourService_cmV6YW9ubGluZS5uZXQ="
   Prefixes (1)
  ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
   Ports (1):
  (YourService_cmV6YW9ubGluZS5uZXQ=Port)
     Methods (2):
        your_method(xs:string _your_param)
     Types (48):
        ns0:Array
        ns0:ENTITIES
        ns0:ENTITY
        ns0:ID
        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:hexBinary
        ns0:int
        ns0:integer
        ns0:language
        ns0:long
        ns0:negativeInteger
        ns0:positiveInteger
        ns0:short
        ns0:string
        ns0:time
        ns0:token
然后找到合适的参数类型,并按以下方式创建参数:

your_param = client.factory.create("ns0:string")
your_param.value = your_value
(复杂类型遵循复杂方式!)

现在,您可以按如下方式调用您的方法:

client.service.your_method(your_param)
好好享受吧