views:

156

answers:

2

Hello,

I have several devices on a network. I am trying to use a library to discover the presence and itentity of these devices using Python script, the devices all have a web service. My question is, are there any modules that would help me with this problem as the only module I have found is ws-discovery for Python?

And if this is the only module does anyone have any example Python script using ws-discovery?

Thanks for any help.

A: 

Unfortunately I've never used ws-discovery myself, but there seems to be a Python project which implements it: http://code.google.com/p/python-ws-discovery/

From their documentation here's a short example on how to use it:

wsd = WSDiscovery()
wsd.start()

ttype = QName("abc", "def")

ttype1 = QName("namespace", "myTestService")
scope1 = Scope("http://myscope")
ttype2 = QName("namespace", "myOtherTestService_type1")
scope2 = Scope("http://other_scope")

xAddr = "localhost:8080/abc"
wsd.publishService(types=[ttype], scopes=[scope2], xAddrs=[xAddr])

ret = wsd.searchServices()

for service in ret:
    print service.getEPR() + ":" + service.getXAddrs()[0]

wsd.stop()
rlotun
I had used this code already and got it working, it was something on my server side. You use `service.getXAddrs()[0]` to get the xaddress of the first service etc. Thanks for helping anyway
chrissygormley
A: 

Are you tied to ws-discovery? If not, you might want to consider the Bonjour protocol, aka ZeroConf and DNS-SD. The protocol is relatively widely implemented. I've never used python to do the advertising or discovery but there is a project that implements an API: http://code.google.com/p/pybonjour/

As I said, I have no direct experience with this project and merely point it out as an alternative to ws-discovery.

tikiboy