Exemplo n.º 1
0
 def __find(self, name):
     """
     Find a I{service} by name (string) or index (integer).
     @param name: The name (or index) of a service.
     @type name: (int|str)
     @return: A L{PortSelector} for the found service.
     @rtype: L{PortSelector}.
     """
     service = None
     if not len(self.__services):
         raise Exception('No services defined')
     if isinstance(name, int):
         try:
             service = self.__services[name]
             name = service.name
         except IndexError:
             raise ServiceNotFound('at [%d]' % name)
     else:
         for s in self.__services:
             if name == s.name:
                 service = s
                 break
     if service is None:
         raise ServiceNotFound(name)
     return PortSelector(self.__client, service.ports, name)
Exemplo n.º 2
0
    def set_location(self, url, service=None, names=None):
        """Sets location to use in future requests.

        This is for when the location(s) specified in the WSDL are not correct.
        `service` is the name or index of the service to change and ignored
        unless there is more than one service. `names` should be either a
        comma-delimited list of methods names or an iterable (e.g. a list). If
        no methods names are given, then sets the location for all methods of
        the service(s).

        Example:
        | Set Location | http://localhost:8080/myWS |
        """
        wsdl = self._client().wsdl
        service_count = len(wsdl.services)
        if (service_count == 1):
            service = 0
        elif not service is None:
            service = parse_index(service)
        if isinstance(names, basestring):
            names = names.split(",")
        if service is None:
            for svc in wsdl.services:
                svc.setlocation(url, names)
        elif isinstance(service, int):
            wsdl.services[service].setlocation(url, names)
        else:
            for svc in wsdl.services:
                if svc.name == service:
                    svc.setlocation(url, names)
                    return
            raise ServiceNotFound(service)