Browse Source

Finish up what Mark Bucciarelli kicked off and I started with

commit a little while ago. :)  That is, wstools is now independant
of SOAPpy and ZSI.  This commit does the following:
    wstools/ServiceProxy.py is now ZSI/ServiceProxy.py, so some
    imports and ZSI docs had to change.
ZSI needs some changing, in case I didn't patch up all the imports
right.
main
Rich Salz 21 years ago
parent
commit
cbe6997499
2 changed files with 2 additions and 94 deletions
  1. +0
    -82
      ServiceProxy.py
  2. +2
    -12
      __init__.py

+ 0
- 82
ServiceProxy.py View File

@@ -1,82 +0,0 @@
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.

from ZSI import *
from ZSI.client import *
import WSDLTools
from urlparse import urlparse
import weakref

class ServiceProxy:
"""A ServiceProxy provides a convenient way to call a remote web
service that is described with WSDL. The proxy exposes methods
that reflect the methods of the remote web service."""

def __init__(self, wsdl, service=None, port=None, tracefile=None,
typesmodule=None, nsdict=None):
if not hasattr(wsdl, 'targetNamespace'):
wsdl = WSDLTools.WSDLReader().loadFromURL(wsdl)
# for item in wsdl.types.items():
# self._serializer.loadSchema(item)
self._service = wsdl.services[service or 0]
self.__doc__ = self._service.documentation
self._port = self._service.ports[port or 0]
self._name = self._service.name
self._wsdl = wsdl
self._tracefile = tracefile
self._typesmodule = typesmodule
self._nsdict = nsdict
binding = self._port.getBinding()
portType = binding.getPortType()
for item in portType.operations:
callinfo = callInfoFromWSDL(self._port, item.name)
method = MethodProxy(self, callinfo)
setattr(self, item.name, method)

def _call(self, name, *args, **kwargs):
"""Call the named remote web service method."""
if len(args) and len(kwargs):
raise TypeError(
'Use positional or keyword argument only.'
)

callinfo = getattr(self, name).callinfo
url = callinfo.location
(protocol, host, uri, query, fragment, identifier) = urlparse(url)
port = 80
if host.find(':') >= 0:
host, port = host.split(':')

params = callinfo.getInParameters()
host = str(host)
port = str(port)

binding = Binding(host=host, tracefile=self._tracefile,
ssl=(protocol == 'https'),
port=port, url=uri, typesmodule=self._typesmodule,
nsdict=self._nsdict)

apply(getattr(binding, callinfo.methodName), args)


#print binding.ReceiveRaw()

return binding.Receive()


class MethodProxy:
""" """
def __init__(self, parent, callinfo):
self.__name__ = callinfo.methodName
self.__doc__ = callinfo.documentation
self.callinfo = callinfo
self.parent = weakref.ref(parent)

def __call__(self, *args, **kwargs):
return self.parent()._call(self.__name__, *args, **kwargs)

+ 2
- 12
__init__.py View File

@@ -1,14 +1,4 @@
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.

#! /usr/bin/env python
"""WSDL parsing services package for Web Services for Python."""

from ServiceProxy import ServiceProxy
import ieee754
import XMLname
import WSDLTools, ieee754, XMLname

Loading…
Cancel
Save