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信息头管理器python3 + spyn的 webservice ,分别使用python + suds-jurko 和 jmeter 接口调用
  2. SOAP/XML-RPC Requestpython3 + spyn的 webservice ,分别使用python + suds-jurko 和 jmeter 接口调用
    <?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. 察看结果树python3 + spyn的 webservice ,分别使用python + suds-jurko 和 jmeter 接口调用