首页 > 解决方案 > 无法从 Python 中的 SOAP 请求生成响应

问题描述

我正在使用本地 url 开发一个 API:http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService?wsdl 这需要打开 Bio-Rad CFX 应用程序才能访问该 url。

我使用以下代码使用 zeep 库创建了客户端: client = Client(wsdl = 'http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService?wsdl')

API 服务XmlCommand需要 xml 作为输入,因此我使用dicttoxml库将我的 Python 对象转换为 xml

def Message2XML(message_type_object):
message = dicttoxml.dicttoxml(message_type_object, custom_root='Message')
return message

data = {'RegistrationID': "", 
    'RegisterService': ""}
    
xml = Message2XML(data)

python -mzeep http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService?wsdl在控制台上运行会给出:

Service: SOCFXCommandService
 Port: WSDualHttpBinding_ISOCFXCommandService (Soap12Binding: {http://tempuri.org/}WSDualHttpBinding_ISOCFXCommandService)
     Operations:
        OnServiceIsClosing(missing input message)
        SubscribeToServiceIsClosing() ->
        XmlCommand(xml: xsd:string) -> XmlCommandResult: xsd:string

输出控制台只是给出一个None响应,即使它应该返回一个 xml 输出。以下是发送的消息和我得到的回复。

<?xml version="1.0" ?>
<Message>
    <RegistrationID type="str"/>
    <RegisterService type="str"/>
</Message>

None

标签: pythonapisoap

解决方案


推荐阅读