<commit_before>#
# soaplib - Copyright (C) 2009 <NAME>, <NAME>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
#
'''
The tests in this module confirm that soaplib can interoperate with common
SOAP implementations found on the web.
'''

from soaplib.parsers.wsdlparse import WSDLParser
import lxml.etree as et
import urllib2 as ulib
from soaplib.client import make_service_client



wp = WSDLParser.from_url('http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl')
print wp.services

UserManager = wp.services['UserManager']
User = wp.ctypes['{UserManager.UserManager}User']
user = User()
user.username = 'john_smith'
user.firstname = 'john'
user.surname = 'smith'
client = make_service_client('http://localhost:7789/', UserManager())
userid = client.add_user(user)
print "adding user - id: %s" % userid
users = client.list_users()
for u in users:
    print u.username
 
<commit_msg>Revert changes to interop_service.py.<commit_after>#
# soaplib - Copyright (C) 2009 <NAME>, <NAME>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
#

from soaplib.service import soapmethod
from soaplib.serializers.binary import Attachment
from soaplib.serializers.clazz import ClassSerializer
from soaplib.serializers.primitive import (
    String, Integer, DateTime, Float, Boolean, Array)
from soaplib.wsgi_soap import SimpleWSGISoapApp, log_debug, log_exceptions


class SimpleClass(ClassSerializer):

    class types:
        i = Integer
        s = String


class OtherClass(ClassSerializer):

    class types:
        dt = DateTime
        f = Float
        b = Boolean


class NestedClass(ClassSerializer):

    class types:
        simple = Array(SimpleClass)
        s = String
        i = Integer
        f = Float
        other = OtherClass


class InteropService(SimpleWSGISoapApp):

    # basic primitives

    @soapmethod(Integer, _returns=Integer)
    def echoInteger(self, i):
        return i

    @soapmethod(String, _returns=String)
    def echoString(self, s):
        return s

    @soapmethod(DateTime, _returns=DateTime)
    def echoDateTime(self, dt):
        return dt

    @soapmethod(Float, _returns=Float)
    def echoFloat(self, f):
        return f

    @soapmethod(Boolean, _returns=Boolean)
    def echoBoolean(self, b):
        return b

    # lists of primitives

    @soapmethod(Array(Integer), _returns=Array(Integer))
    def echoIntegerArray(self, ia):
        return ia

    @soapmethod(Array(String), _returns=Array(String))
    def echoStringArray(self, sa):
        return sa

    @soapmethod(Array(DateTime), _returns=Array(DateTime))
    def echoDateTimeArray(self, dta):
        return dta

    @soapmethod(Array(Float), _returns=Array(Float))
    def echoFloatArray(self, fa):
        return fa

    @soapmethod(Array(Boolean), _returns=Array(Boolean))
    def echoBooleanArray(self, ba):
        return ba

    # classses

    @soapmethod(SimpleClass, _returns=SimpleClass)
    def echoSimpleClass(self, sc):
        return sc

    @soapmethod(Array(SimpleClass), _returns=Array(SimpleClass))
    def echoSimpleClassArray(self, sca):
        return sca

    @soapmethod(NestedClass, _returns=NestedClass)
    def echoNestedClass(self, nc):
        return nc

    @soapmethod(Array(NestedClass), _returns=Array(NestedClass))
    def echoNestedClassArray(self, nca):
        return nca

    @soapmethod(Attachment, _returns=Attachment)
    def echoAttachment(self, a):
        return a

    @soapmethod(Array(Attachment), _returns=Array(Attachment))
    def echoAttachmentArray(self, aa):
        return aa

    @soapmethod()
    def testEmpty(self):
        # new
        pass

    @soapmethod(String, Integer, DateTime)
    def multiParam(self, s, i, dt):
        # new
        pass

    @soapmethod(_returns=String)
    def returnOnly(self):
        # new
        return 'howdy'

    @soapmethod(String, _returns=String,
        _soapAction="http://sample.org/webservices/doSomething")
    def doSomethingElse(self, s):
        return s


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
        log_debug(True)
        log_exceptions(True)
        server = make_server('127.0.0.1', 9753, InteropService())
        print 'Starting interop server at -- %s:%s' % ('127.0.0.1', 9753)
        server.serve_forever()
    except ImportError:
        print "Error: example server code requires Python >= 2.5"
{'fraction_non_alphanumeric': 0.0884662362589426, 'fraction_numerical': 0.010818356307799686, 'mean_word_length': 3.502749410840534, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2610594', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1657, 'n_words': 557}