pythonweb-servicesws-discovery

Discovery of web services using Python


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.


Solution

  • Unfortunately I've never used ws-discovery myself, but there seems to be a Python project which implements it: https://pypi.org/project/WSDiscovery/

    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()