2011-10-31 48 views
0

我對Python和Suds是全新的。爲了測試不同的客戶端,我成功地使用了C#,java,perl,現在術語是關於Python-suds的......可以幫助一些人。 .. 這裏是客戶端代碼----複雜的SOAP請求打印單線響應

from suds.client import Client 
wsdl = 'http://www.cbs.dtu.dk/ws/SignalP/SignalP_3_1_ws0.wsdl' 
client = Client(wsdl) 
seq="""val1 
val2 
val3""" 
print client.service.runService(seq) 

,併發送請求包絡....

<parameters> 
<organism> val1 
</organism> 
<sequencedata> 
     <sequence> 
      <id>val2</id> 
      <seq>val3</seq> 
     </sequence> 
    </sequencedata> 
</parameters> 

回答

0

我想出了一個答案自己,但現在看來,這不是100%;我收到了正確的回覆信封,但請求信封的格式不正確,爲val2val3

在這裏,我乾脆把(我用的記錄知道輸入/輸出中):

from suds.client import Client 
import logging 

logging.basicConfig(level=logging.INFO) 
logging.getLogger('suds.client').setLevel(logging.DEBUG) 

# soap messages (in&out) and http headers 
wsdl = 'http://www.cbs.dtu.dk/ws/SignalP/SignalP_3_1_ws0.wsdl' 
client = Client(wsdl, cache=None,) 

seq = client.factory.create('ns1:sequence') 
seq.id="XXXXX" 
seq.seq="KBVGHGKLGKLGKHGJHG" 

req = client.factory.create('ns1:method') 
req.parameters.organism="val1" 
req.parameters.sequencedata.sequence=seq; 
response = client.service.runService(req) 
+0

嗯,我不明白,你把VAL2和VAL3呢? – webbi