复杂的SOAP请求打印单行响应

时间:2011-10-31 09:44:54

标签: python soap suds

我是Python和Sud的新手。为了测试不同的客户端,我成功地使用了C#,java,perl,现在这个术语是关于Python-suds ...可以帮助... 这是客户端代码----

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>

1 个答案:

答案 0 :(得分:0)

我自己想出了一个答案,但似乎不是100%;我收到了正确的回复信封,但请求信封的格式不正确val2val3

这里我完全放了(我用log来知道输入/输出):

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)