从 Windows 7 开始,支持 PnP 扩展(PnP-X)和 Web 服务设备配置文件(DPWS)的设备可以通过在设备元数据文档中包括 ContainerId XML 元素来指定容器 ID。 有关 DPWS 和 DPWS 设备元数据文档的详细信息,请参阅 DPWS 规范。
注释
从 Windows 10 开始,系统会忽略设备提供的容器 ID,而是自行生成一个。 它通过使用设备的终结点引用地址(EPR)中的 GUID 或设备的 EPR(如果不是 GUID)的 SHA-1 哈希来实现这一功能。
ContainerId XML 元素声明如下:
<df:ContainerId xmlns:df="">
xs:string
</df:ContainerId>
ContainerId XML 元素类型是一个字符串,其值为格式化的全局唯一标识符(GUID)。 此字符串的格式设置为 {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxx}。
下面是 ContainerId XML 元素的示例。
<df:ContainerId xmlns:df="">
{101392d0-5e91-11dd-ad8b-0800200c9a66}
</df:ContainerId>
<ContainerId> XML 元素必须位于简单对象访问协议 (SOAP) 的设备元数据交换信息的<ThisDevice>部分中。 以下示例展示了 <ContainerId> 元素在元数据交换消息中的正确位置。
注释
这不是完整的 DPWS 元数据交换文档。 有关 DPWS 的详细信息,请参阅 DPWS 规范。
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsdisco="http://schemas.xmlsoap.org/ws/2005/04/discovery"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsd="http://schemas.xmlsoap.org/ws/2006/02/devprof"
xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation">
<soap:Header>
<!-- Place SOAP header information here.-->
</soap:Header>
<soap:Body>
<wsx:Metadata>
<wsx:MetadataSection
Dialect="http://schemas.xmlsoap.org/ws/2005/05/devprof/ThisModel">
<wsd:ThisDevice>
<!-- Place ThisDevice metadata here.-->
<df:ContainerId>
<!--- Place the ContainerID GUID here.--->
{101392d0-5e91-11dd-ad8b-0800200c9a66}
</df:ContainerId>
</wsd:ThisDevice>
</wsx:MetadataSection>
</wsx:Metadata>
</soap:Body>
</soap:Envelope>
如果 DPWS 设备元数据文档不包含 ContainerId XML 元素,即插即用(PnP)管理器将使用设备的终结点引用地址的值作为容器 ID。