views:

20

answers:

1

Hello,

I am using the WSDiscovery module for python. I have been able to search for services on my network. I am trying to discover a client and get the XAddress from this. The WSDiscovery module has very little documentation, actually so little the only piece is in the readme file of the module which is a few lines long. I have manged to get this specific code working below:

import WSDiscovery
from WSDiscovery import WSDiscovery

def printService():
    wsd = WSDiscovery()
    wsd.start()
    services = wsd.searchServices()
    for service in services:
        try:
            print service.getEPR() + ":" + str(service.getXAddrs())
            print service.getTypes()
        except:
            print "Error with "+service.getEPR()

    wsd.stop()

This get's all services and I can get different XAddresses using:

service.getXAddrs()[0]

But I am looking for one in particular with a specific id. The one of the addresses would come up as:

4yr8343-r48d-3ref-4fsw-5r4tw432:[u'http://10.10.10.10:5321']

Can anyone think of a suggestion to select the address with this id number for example.

Thanks

+1  A: 

Looking at sources you could see that

1. searchServices signature has few parameters:

def searchServices(self, types=None, scopes=None, timeout=3)

and i don't think filtering by types\scopes can be useful, isn't it?

2. service CLASS has those parameters:

class Service:

def __init__(self, types, scopes, xAddrs, epr, instanceId):
    self.__types = types
    self.__scopes = scopes
    self.__xAddrs = xAddrs
    self.__epr = epr
    self.__instanceId = instanceId
    self.__messageNumber = 0
    self.__metadataVersion = 1

For what i see, the only thing you could do is iterate over services retrieved by searchServices and filter by one of the attributes available.

systempuntoout
@systempuntoout -- Yeah, it look's that way. I suppose I could look through each service in the for loop and match by string. Can you think of any other way's apart from the for loop?
chrissygormley
@chrissygormley I can't :). Looking at the source code, matching by string seems the only path available.
systempuntoout