简体   繁体   English

使用 Python 发现 Web 服务

[英]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.我正在尝试使用一个库来使用 Python 脚本来发现这些设备的存在和实体,这些设备都有一个 Web 服务。 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?我的问题是,是否有任何模块可以帮助我解决这个问题,因为我发现的唯一模块是 Python 的 ws-discovery?

And if this is the only module does anyone have any example Python script using ws-discovery?如果这是唯一的模块,是否有人有任何使用 ws-discovery 的 Python 脚本示例?

Thanks for any help.谢谢你的帮助。

Unfortunately I've never used ws-discovery myself, but there seems to be a Python project which implements it: https://pypi.org/project/WSDiscovery/不幸的是,我自己从未使用过 ws-discovery,但似乎有一个 Python 项目实现了它: 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()

Are you tied to ws-discovery?您是否与 ws-discovery 相关? If not, you might want to consider the Bonjour protocol, aka ZeroConf and DNS-SD.如果没有,您可能需要考虑 Bonjour 协议,即 ZeroConf 和 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/我从来没有用过 python 来做广告或发现,但有一个实现 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.正如我所说,我对这个项目没有直接经验,只是指出它是 ws-discovery 的替代方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM