我想将带有out_protocol=XmlDocument()
的Pandas数据帧公开为SOAPweb服务。在
到目前为止,我只设法通过调用带有HTTP
的web服务来公开String
。这是工作代码。在
服务器代码:
from spyne import Application, srpc, ServiceBase, \
Integer, Unicode, String
from spyne import Iterable
from spyne.protocol.http import HttpRpc
from spyne.protocol.soap import Soap11
from spyne.protocol.json import JsonDocument
from spyne.protocol.xml import XmlDocument
from spyne.server.wsgi import WsgiApplication
class HelloWorldService(ServiceBase):
@srpc(String, Integer, _returns=String)
def say_hello(name, times):
s = ('Hi' + str(name)+' ')*times
return s
application = Application([HelloWorldService],
tns='spyne.examples.hello.http',
in_protocol=HttpRpc(), #Soap11 for SOAP client
out_protocol=XmlDocument()
)
if __name__ == '__main__':
from wsgiref.simple_server import make_server
wsgi_app = WsgiApplication(application)
server = make_server('127.0.0.1', 8000, wsgi_app)
server.serve_forever()
客户代码:
^{pr2}$我应该如何更改代码以最好地公开Pandas数据帧而不是字符串。以及如何让客户机使用SOAP协议发出请求?在
我对SOAP客户端的尝试:
from zeep import Client
client = Client('http://localhost:8000/?wsdl')
result = client.service.say_hello("Antonio", 10)
print(result)
web服务的预期输出应该是类似xml的表。下面是一个例子:
Soap服务在web服务中固有地使用
xml
。根据这个问题,我认为您需要xml
来向服务器提供提要!!正如您所说,您可以将
result
转换为pandas DF,然后从DF转换为xml,link:相关问题 更多 >
编程相关推荐