开发者

Get a specific string from a service list using WSDiscovery

开发者 https://www.devze.com 2022-12-25 10:43 出处:网络
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 li

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 doc开发者_StackOverflowumentation, 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号