python3 + spyn的 webservice ,分别使用python + suds-jurko 和 jmeter 接口调用

  • python3.6 + spyne webservice 示例:
from spyne import Application,rpc,ServiceBase,Iterable,Integer,Unicode
from spyne.protocol.soap import Soap11,Soap12
from spyne.server.wsgi import WsgiApplication

class HelloWorldService1(ServiceBase):
    @rpc(Unicode,Integer,_returns=Iterable(Unicode))
    def say_hello11(ctx,name,times):
        """Docstrings for service methods appear as documentation in the wsdl.
        <b>What fun!</b>
        @param name the name to say hello to
        @param times the number of times to say hello
        @return the completed array
        """
        for i in range(times):
            yield u'say_hello11 : Hello,%s' % name
    @rpc(Unicode,Integer,_returns=Iterable(Unicode))

    def say_hello12(ctx,name,times):
        """Docstrings for service methods appear as documentation in the wsdl.
        <b>What fun!</b>
        @param name the name to say hello to
        @param times the number of times to say hello
        @return the completed array
        """
        for i in range(times):
            yield u'say_hello12 : Hello,%s' % name

class HelloWorldService2(ServiceBase):
    @rpc(Unicode,Integer,_returns=Iterable(Unicode))
    def say_hello21(ctx,name,times):
        """Docstrings for service methods appear as documentation in the wsdl.
        <b>What fun!</b>
        @param name the name to say hello to
        @param times the number of times to say hello
        @return the completed array
        """
        for i in range(times):
            yield u'say_hello21 : Hello,%s' % name

    @rpc(Unicode,Integer,_returns=Iterable(Unicode))
    def say_hello22(ctx,name,times):
        """Docstrings for service methods appear as documentation in the wsdl.
        <b>What fun!</b>
        @param name the name to say hello to
        @param times the number of times to say hello
        @return the completed array
        """
        for i in range(times):
            yield u'say_hello22 : Hello,%s' % name

application = Application([HelloWorldService1,HelloWorldService2],'http://schemas.xmlsoap.org/soap/envelope',in_protocol=Soap11(validator='lxml'),out_protocol=Soap11())
wsgi_application = WsgiApplication(application)

if __name__ == '__main__':
    import logging
    from wsgiref.simple_server import make_server
    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)
    logging.info("listening to http://192.168.1.68:8000")
    logging.info("wsdl is at: http://192.168.1.68:8000/?wsdl")
    server = make_server('192.168.1.68',8000,wsgi_application)
    server.serve_forever()
  • python3.6 + suds-jurko 调用上述webservice
from suds.client import Client

url = 'http://192.168.1.68:8000/?wsdl'
client = Client(url)
print(client)

res = client.service.say_hello11('zhangsan',1)
print(res)
print('='*20)
# res = client.service.say_hello12('lisi',2)
# print(res)
# print('='*20)
# res = client.service.say_hello21('wangwu',3)
# print(res)
# print('='*20)
# res = client.service.say_hello22('luliu',4)
# print(res)
  • jmeter 3.0 调用上述webservice
  1. HTTP信息头管理器
  2. SOAP/XML-RPC Request
    <?xml version="1.0" encoding="utf-8"?>
    <soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ord="http://order.itms.zznode.com">
    <soap11env:Body>
    <say_hello11 xmlns="http://schemas.xmlsoap.org/soap/envelope">
    <name>zhangsan</name>
    <times>5</times>
    </say_hello11>
    </soap11env:Body>
    </soap11env:Envelope>

     

  3. 察看结果树
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

生命的脚步从不停歇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值