使用Spyne soap服务器的合格元素属性表单和不合格表单

使用Spyne soap服务器的合格元素属性表单和不合格表单,第1张

概述有没有办法使用spyne服务器的elementFormDefault =“非限定”服务器架构类型? 现在我的所有试验都以方法响应结果结束: <senv:Envelope xmlns:tns="http://test.com/remoteService/"xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"><senv:Body> 有没有办法使用spyne服务器的elementFormDefault =“非限定”服务器架构类型?
现在我的所有试验都以方法响应结果结束:

<senv:Envelope xmlns:tns="http://test.com/remoteService/"xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"><senv:Body>    <tns:testResponse>        <tns:status>ok</tns:status>    </tns:testResponse></senv:Body>

并使用“qualifIEd”elementFormDefault生成wsdl片段:

<xs:schema targetnamespace="http://test.com/remoteService/" elementFormDefault="qualifIEd"></xs:schema>

如何配置方法或参数模型以获得如下结果:

<senv:Envelope xmlns:tns="http://test.com/remoteService/"xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"><senv:Body>    <tns:testResponse>        <status>ok<status>    </tns:testResponse></senv:Body>

我的目标是生成子元素的结果:

<tns:status>ok</tns:status>

将出现没有名称空间前缀 – 像这样:

<status>ok<status>
解决方法 如果您想知道如何将侦听器添加到method_return_string的event_manager或其他事件,请参阅下面的完整示例:

from spyne import Application,rpc,ServiceBase,Iterable,Integer,Unicodefrom spyne.protocol.soap import Soap11from spyne.server.wsgi import WsgiApplicationclass HelloWorldService(ServiceBase):    @rpc(Unicode,_returns=Iterable(Unicode))    def say_hello(ctx,name,times):        for i in range(times):            yIEld u'Hello,%s' % namedef on_method_return_string(ctx):    ctx.out_string[0] = ctx.out_string[0].replace(b'Hello>',b'Good by')HelloWorldService.event_manager.add_Listener('method_return_string',on_method_return_string)application = Application([HelloWorldService],'spyne.examples.hello.soap',in_protocol=Soap11(valIDator='lxml'),out_protocol=Soap11())wsgi_application = WsgiApplication(application)if __name__ == '__main__':    import logging    from wsgiref.simple_server import make_server    server = make_server('127.0.0.1',8000,wsgi_application)    server.serve_forever()

从Spyne 2.12开始,这仍然是从响应变量中删除命名空间的唯一方法.

总结

以上是内存溢出为你收集整理的使用Spyne soap服务器的合格元素/属性表单和不合格表单全部内容,希望文章能够帮你解决使用Spyne soap服务器的合格元素/属性表单和不合格表单所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1060446.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存