Example #1
0
 def test_exception(self):
     try:
         Attachment.to_xml(Attachment())
     except:
         self.assertTrue(True)
     else:
         self.assertFalse(True)
Example #2
0
 def test_from_xml(self):
     f = open(self.tmpfile)
     data = f.read()
     f.close()
     a = Attachment()
     a.data = data
     element = Attachment.to_xml(a)
     a2 = Attachment.from_xml(element)
     self.assertEquals(data, a2.data)
Example #3
0
 def test_to_from_xml_file(self):
     a = Attachment()
     a.fileName = self.tmpfile
     element = Attachment.to_xml(a)
     data = Attachment.from_xml(element).data
     f = open(self.tmpfile, 'rb')
     fdata = f.read()
     f.close()
     self.assertEquals(data, fdata)
Example #4
0
 def test_to_xml_file(self):
     a = Attachment()
     a.fileName = self.tmpfile
     f = open(self.tmpfile, 'rb')
     data = f.read()
     f.close()
     element = Attachment.to_xml(a)
     encoded_data = base64.encodestring(data)
     self.assertNotEquals(element.text, None)
     self.assertEquals(element.text, encoded_data)
Example #5
0
 def test_to_xml_data(self):
     f = open(self.tmpfile)
     data = f.read()
     f.close()
     a = Attachment()
     a.data = data
     element = Attachment.to_xml(a)
     encoded_data = base64.encodestring(data)
     self.assertNotEquals(element.text, None)
     self.assertEquals(element.text, encoded_data)
Example #6
0
    def get_archived_document(self, file_path):
        '''
        This method loads a document from the specified file path
        and returns it.  If the path isn't found, an exception is
        raised.
        '''
        if not os.path.exists(file_path):
            raise Exception("File [%s] not found" % file_path)

        document = Attachment(fileName=file_path)
        # the service automatically loads the data from the file.
        # alternatively, The data could be manually loaded into memory
        # and loaded into the Attachment like:
        #   document = Attachment(data=data_from_file)
        return document
Example #7
0
#!/usr/bin/env python
#
# soaplib - Copyright (C) 2009 Aaron Bickell, Jamie Kirkpatrick
#
# 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.client import make_service_client
from soaplib.serializers.binary import Attachment
from helloworld_attach import HelloWorldService
from soaplib.client import debug
debug(True)

client = make_service_client('http://localhost:7789/', HelloWorldService())
print client.say_hello(Attachment(data="Dave"), 5, mtom=True)