コード例 #1
0
ファイル: server.py プロジェクト: rgoliveira/forca
            request, response, doc = dispatcher.help(method)
            ##print request
            ##print response

    if '--serve' in sys.argv:
        print "Starting server..."
        httpd = HTTPServer(("", 8008), SOAPHandler)
        httpd.dispatcher = dispatcher
        httpd.serve_forever()

    if '--consume' in sys.argv:
        from client import SoapClient
        client = SoapClient(
            location="http://localhost:8008/",
            action='http://localhost:8008/',  # SOAPAction
            namespace="http://example.com/sample.wsdl",
            soap_ns='soap',
            trace=True,
            ns=False)
        response = client.Adder(p={
            'a': 1,
            'b': 2
        },
                                dt='20100724',
                                c=[{
                                    'd': '1.20'
                                }, {
                                    'd': '2.01'
                                }])
        result = response.AddResult
        print int(result.ab)
コード例 #2
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
if sys.version > '3':
    long = int

if __name__ == "__main__":
    import sys

    if '--web2py' in sys.argv:
        # test local sample webservice exposed by web2py
        from client import SoapClient
        if not '--wsdl' in sys.argv:
            client = SoapClient(
                location="http://127.0.0.1:8000/webservices/sample/call/soap",
                action='http://127.0.0.1:8000/webservices/sample/call/soap',  # SOAPAction
                namespace="http://127.0.0.1:8000/webservices/sample/call/soap",
                soap_ns='soap', ns=False, exceptions=True)
        else:
            client = SoapClient(wsdl="http://127.0.0.1:8000/webservices/sample/call/soap?WSDL")
        response = client.Dummy()
        print('dummy', response)
        response = client.Echo(value='hola')
        print('echo', repr(response))
        response = client.AddIntegers(a=1, b=2)
        if not '--wsdl' in sys.argv:
            result = response.AddResult  # manully convert returned type
            print(int(result))
        else:
            result = response['AddResult']
            print(result, type(result), "auto-unmarshalled")
コード例 #3
0
            ":")
    return proxy_dict


if __name__ == "__main__":
    import sys

    if '--web2py' in sys.argv:
        # test local sample webservice exposed by web2py
        from client import SoapClient
        if not '--wsdl' in sys.argv:
            client = SoapClient(
                location="http://127.0.0.1:8000/webservices/sample/call/soap",
                action=
                'http://127.0.0.1:8000/webservices/sample/call/soap',  # SOAPAction
                namespace="http://127.0.0.1:8000/webservices/sample/call/soap",
                soap_ns='soap',
                trace=True,
                ns=False,
                exceptions=True)
        else:
            client = SoapClient(
                wsdl="http://127.0.0.1:8000/webservices/sample/call/soap?WSDL",
                trace=True)
        response = client.Dummy()
        print 'dummy', response
        response = client.Echo(value='hola')
        print 'echo', repr(response)
        response = client.AddIntegers(a=1, b=2)
        if not '--wsdl' in sys.argv:
            result = response.AddResult  # manully convert returned type
コード例 #4
0
            request, response, doc = dispatcher.help(method)

    if '--serve' in sys.argv:
        log.info("Starting server...")
        httpd = HTTPServer(("", 8008), SOAPHandler)
        httpd.dispatcher = dispatcher
        httpd.serve_forever()

    if '--wsgi-serve' in sys.argv:
        log.info("Starting wsgi server...")
        from wsgiref.simple_server import make_server
        application = WSGISOAPHandler(dispatcher)
        wsgid = make_server('', 8008, application)
        wsgid.serve_forever()

    if '--consume' in sys.argv:
        from client import SoapClient
        client = SoapClient(
            location="http://localhost:8008/",
            action='http://localhost:8008/',  # SOAPAction
            namespace="http://example.com/sample.wsdl",
            soap_ns='soap',
            trace=True,
            ns=False)
        p = {'a': 1, 'b': 2}
        c = [{'d': '1.20'}, {'d': '2.01'}]
        response = client.Adder(p=p, dt='20100724', c=c)
        result = response.AddResult
        log.info(int(result.ab))
        log.info(str(result.dd))