ws-discovery该例子来自于ws-discovery.pdf,连接如下,表1和表2是对该例子的解释进行翻译,表3个是一个onvif的搜索响应
ProbeMatches 消息 - Win32 apps | Microsoft Learn(microsoft的中文文档)
(01) <s:Envelope
(02) xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"
(03) xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
(04) xmlns:i="http://printer.example.org/2003/imaging"
(05) xmlns:s="http://www.w3.org/2003/05/soap-envelope" >
(06) <s:Header>
(07) <a:Action>
(08) http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe
(09) </a:Action>
(10) <a:MessageID>
(11) uuid:0a6dc791-2be6-4991-9af1-454778a1917a
(12) </a:MessageID>
(13) <a:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
(14) </s:Header>
(15) <s:Body>
(16) <d:Probe>
(17) <d:Types>i:PrintBasic</d:Types>
(18) <d:Scopes
(19) MatchBy="http://schemas.xmlsoap.org/ws/2005/04/discovery/ldap" >
(20) ldap:///ou=engineering,o=examplecom,c=us
(21) </d:Scopes>
(22) </d:Probe>
(23) </s:Body>
(24) </s:Envelope>
上表的7到9行表明这是一个Probe(嗅探),13行表明该消息发送到一个众所周知的地址(well-known)[RFC2141] (RFC2141是urn的语法说明,urn的意思是“统一资源名称”。
在ws-discovery文档的5.2节中特别有说明,当我们是发送给目标服务而不是代理时必须是:
urn:schemas-xmlsoap-org:ws:2005:04:discovery)。
因为在Header块里没有ReplyTo字段,那么任何对该Probe消息的响应都应该通过UDP发送到该soap消息头部说明的源ip和端口上[SOAP/UDP](SOAP-over-UDP的文档).
17到21行指明了Probe的两个限制,17行限制了响应是实现了基本打印服务的类别,18到21行在工程范畴上对其做了限制。只有当目标服务同时满足这两个限制时,才需要对该Probe做出响应。
虽然这个例子中同时包含了这两个限制,但是实际使用中一个Probe并不要求同时包含他们。
下面的表2是对表1的响应。
(01) <s:Envelope
(02) xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"
(03) xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
(04) xmlns:i="http://printer.example.org/2003/imaging"
(05) xmlns:s="http://www.w3.org/2003/05/soap-envelope" >
(06) <s:Header>
(07) <a:Action>
(08) http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches
(09) </a:Action>
(10) <a:MessageID>
(11) uuid:e32e6863-ea5e-4ee4-997e-69539d1ff2cc
(12) </a:MessageID>
(13) <a:RelatesTo>
(14) uuid:0a6dc791-2be6-4991-9af1-454778a1917a
(15) </a:RelatesTo>
(16) <a:To>
(17) http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
(18) </a:To>
(19) <d:AppSequence InstanceId="1077004800" MessageNumber="2" />
(20) </s:Header>(21) <s:Body>
(22) <d:ProbeMatches>
(23) <d:ProbeMatch>
(24) <a:EndpointReference>
(25) <a:Address>
(26) uuid:98190dc2-0890-4ef8-ac9a-5940995e6119
(27) </a:Address>
(28) </a:EndpointReference>
(29) <d:Types>i:PrintBasic i:PrintAdvanced</d:Types>
(30) <d:Scopes>
(31) ldap:///ou=engineering,o=examplecom,c=us
(32) ldap:///ou=floor1,ou=b42,ou=anytown,o=examplecom,c=us
(33) http://itdept/imaging/deployment/2004-12-04
(34) </d:Scopes>
(35) <d:XAddrs>http://prn-example/PRN42/b42-1668-a</d:XAddrs>
(36) <d:MetadataVersion>75965</d:MetadataVersion>
(37) </d:ProbeMatch>
(38) </d:ProbeMatches>
(39) </s:Body>
(40) </s:Envelope>
7到9行表明这是一个Probe(嗅探),
13到15行表明是一个对表1的Probe的响应。因为表1的Probe没有ReplyTo头块,
16到18行说明响应该通过UDP发送到Probe的soap消息头部说明的源ip和端口上。(文档5.3节)
19行包含实例标识符和编号。此信息让接收方能对从目标服务接收的发现消息重新排序(因为可能是udp的)。
23到37描述了一个单个目标服务。
24到28描述了。。。
29说明了目标服务实现的类别(Types),在本例中,是与Probe匹配的基本打印类型以及额外的一个高级打印类型。
30到34行列出了3个范畴(scopes)。一个匹配Probe的31行,一个说明了其地理定位信息,一个说明其部署的有用信息(IT部门什么什么的)。在这个例子中,scope是可能是和部署相关的信息集合。
35行表明目标服务可达的地址,在这里是一个http地址。XAddr 验证规则 - Win32 apps | Microsoft Learn
36行是目标服务的版本信息,如果metadata(29行到34行)有变动,版本号递增。
请看7.3节 Discovery definitions ,7.3.2.1节指出有通行的types定义
tds:Device
ONVIF Network Video Transmitter Device Definition
该文档里有NVT(Network Video Transmitter)的定义说明,该文档里说明了types和scops可填写的值(5.2和5.21节)。5.21节指出为了向后兼容,NVT除了tds:Device应有dn:NetworkVideoTransmitter
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery"
xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsa5="http://www.w3.org/2005/08/addressing"
xmlns:xmime="http://tempuri.org/xmime.xsd"
xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2"
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
xmlns:tt="http://www.onvif.org/ver10/schema"
xmlns:ter="http://www.onvif.org/ver10/error"
xmlns:tns1="http://www.onvif.org/ver10/topics"
xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
xmlns:tdn="http://www.onvif.org/ver10/network/wsdl"
xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
xmlns:trp="http://www.onvif.org/ver10/replay/wsdl"
xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl"
xmlns:tr2="http://www.onvif.org/ver20/media/wsdl"
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl"
xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema">
<SOAP-ENV:Header>
<wsa:MessageID>urn:uuid:b51f555f-07a0-4853-915d-0ff352bfdcd6</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:b51f555f-07a0-4853-915d-0ff352bfdcd6</wsa:RelatesTo>
<wsa:To SOAP-ENV:mustUnderstand="true">urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To>
<wsa:Action SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<wsdd:ProbeMatches>
<wsdd:ProbeMatch>
<wsa:EndpointReference>
<wsa:Address>uuid:3fa1fe68-b915-4053-a3e1-ec6073dcb966</wsa:Address>
<wsa:ReferenceProperties></wsa:ReferenceProperties>
<wsa:PortType>ttl</wsa:PortType>
</wsa:EndpointReference>
<wsdd:Types>tdn:NetworkVideoTransmitter</wsdd:Types>
<wsdd:Scopes>onvif://www.onvif.org/name/TP-IPC onvif://www.onvif.org/hardware/MODEL onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/location/ShenZhen onvif://www.onvif.org/type/NetworkVideoTransmitter</wsdd:Scopes>
<wsdd:XAddrs>http://192.168.3.86:2020/onvif/device_service</wsdd:XAddrs>
<wsdd:MetadataVersion>1</wsdd:MetadataVersion>
</wsdd:ProbeMatch>
</wsdd:ProbeMatches>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>