如果通用主机和客户端成功,但实际主机和客户端仍然失败,则可能未启动元数据请求。 WinHTTP 日志记录可用于验证是否正确生成和发送出站消息。
基于 WSDAPI 的客户端应用程序使用 WinHTTP 连接到设备。 基于 WSDAPI 的设备主机不使用 WinHTTP。 此外,某些第三方代理不使用 WinHTTP。 对不使用 WinHTTP 的主机或代理进行故障排除时,请跳过此诊断过程,并按照 检查 HTTP 元数据交换的网络跟踪中的过程继续故障排除。
WinHTTP 日志记录不显示所有 TCP 级流量。 如果对 HTTP 流量以外的流量感兴趣,请跳到 检查 HTTP 元数据交换的网络跟踪 。
使用 WinHTTP 日志记录验证获取流量
- 捕获 WinHTTP 日志。
- 启动记事本或其他文本编辑器。 文本编辑器必须以管理员身份运行。
- 打开 WinHTTP 日志文件。
- 验证是否已发送所需的 HTTP 请求和元数据消息。
如果在 WinHTTP 日志中找到主机的 Get 消息,则元数据请求将成功发送到 WinHTTP。 按照 检查 HTTP 元数据交换的网络跟踪中的过程继续故障排除。
如果在 WinHTTP 日志中找不到主机的 Get 消息,则不会启动元数据请求。 当主机发布无效的 XAddrs 时,可能会发生这种情况。 验证主机上的 XAddrs 是否符合 XAddr 验证规则。
验证是否发送了所需的 HTTP 请求和元数据消息
若要成功交换元数据,必须发生以下事件:
- WSDAPI 客户端生成出站 HTTP 请求。 此请求将发送到 WSDAPI 主机。
- 客户端向主机发送 Get 消息。
这些事件在 WinHTTP 日志中捕获。
以下 WinHTTP 日志文件片段显示 WSDAPI 客户端生成的出站 HTTP 请求。
16:51:47.893 ::*0000004* :: WinHttpSendRequest(0x36aae0, "", 0, 0x0, 0, 658, 0)
16:51:47.893 ::*0000004* :: WinHttpSendRequest() returning TRUE
16:51:47.897 ::*0000004* :: sending data:
16:51:47.897 ::*0000004* :: 226 (0xe2) bytes
16:51:47.897 ::*0000004* :: <<<<-------- HTTP stream follows below ----------------------------------------------->>>>
16:51:47.897 ::*0000004* :: POST /dbe17c74-3b21-4f52-addc-b84b444f73a0 HTTP/1.1
16:51:47.897 ::*0000004* :: Content-Type: application/soap+xml
16:51:47.897 ::*0000004* :: User-Agent: WSDAPI
16:51:47.897 ::*0000004* :: Host: 192.168.0.1:5357
16:51:47.897 ::*0000004* :: Content-Length: 658
16:51:47.897 ::*0000004* :: Connection: Keep-Alive
16:51:47.897 ::*0000004* :: Cache-Control: no-cache
16:51:47.897 ::*0000004* :: Pragma: no-cache
16:51:47.897 ::*0000004* ::
16:51:47.897 ::*0000004* ::
16:51:47.897 ::*0000004* :: <<<<-------- End ----------------------------------------------->>>>
以下 WinHTTP 日志文件代码片段显示 Get 消息。 此消息应紧跟 HTTP 请求。
16:51:47.898 ::*0000004* :: WinHttpWriteData(0x36aae0, 0x11aa7c4, 658, 0x0)
16:51:47.899 ::*0000004* :: sending data:
16:51:47.899 ::*0000004* :: 658 (0x292) bytes
16:51:47.899 ::*0000004* :: <<<<-------- HTTP stream follows below ----------------------------------------------->>>>
16:51:47.899 ::*0000004* :: <?xml version="1.0" encoding="utf-8" ?>
16:51:47.899 ::*0000004* :: <soap:Envelope xmlns:soap="https://www.w3.org/2003/05/soap-envelope" xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing"><soap:Header><wsa:To>urn:uuid:dbe17c74-3b21-4f52-addc-b84b444f73a0</wsa:To><wsa:Action>https://schemas.xmlsoap.org/ws/2004/09/transfer/Get</wsa:Action><wsa:MessageID>urn:uuid:8506ac50-3646-4621-9680-86f484d87909</wsa:MessageID><wsa:ReplyTo><wsa:Address>https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address></wsa:ReplyTo><wsa:From><wsa:Address>urn:uuid:b32467b5-e7ee-4ae3-8a8e-f5aa417c23b6</wsa:Address></wsa:From></soap:Header><soap:Body></soap:Body></soap:Envelope>
16:51:47.899 ::*0000004* :: <<<<-------- End ----------------------------------------------->>>>
16:51:47.899 ::*0000004* :: WinHttpWriteData() returning TRUE
Action 元素 (<wsa:Action>https://schemas.xmlsoap.org/ws/2004/09/transfer/Get</wsa:Action>
) 将消息标识为 Get 消息。 验证 To 元素的值 (例如, <wsa:To>urn:uuid:dbe17c74-3b21-4f52-addc-b84b444f73a0</wsa:To>
) 与主机在原始 UDP WS-Discovery 消息中播发的设备 ID 匹配。 可以使用 WSD 调试主机检查主机播发的设备 ID。 有关详细信息,请参阅 将通用主机和客户端用于 UDP WS-Discovery。
此外,可以在客户端的 WinHTTP 日志中找到主机对元数据请求的响应。 主机生成 GetResponse 消息以响应客户端的 Get 消息。
以下 WinHTTP 日志文件片段显示 WSDAPI 客户端收到的入站 GetResponse 消息。
16:51:47.899 ::*0000004* :: WinHttpReceiveResponse(0x36aae0, 0x0)
16:51:47.899 ::*0000004* :: WinHttpReceiveResponse() returning TRUE
16:51:47.899 ::*Session* :: DllMain(0x73fc0000, DLL_THREAD_ATTACH, 0x0)
16:51:47.902 ::*0000004* :: received data:
16:51:47.902 ::*0000004* :: 1024 (0x400) bytes
16:51:47.902 ::*0000004* :: <<<<-------- HTTP stream follows below ----------------------------------------------->>>>
16:51:47.902 ::*0000004* :: HTTP/1.1 200
16:51:47.902 ::*0000004* :: Content-Type: application/soap+xml
16:51:47.902 ::*0000004* :: Server: Microsoft-HTTPAPI/2.0
16:51:47.902 ::*0000004* :: Date: Fri, 15 Jun 2007 23:51:47 GMT
16:51:47.905 ::*0000004* :: Content-Length: 2228
16:51:47.905 ::*0000004* ::
16:51:47.905 ::*0000004* :: <?xml version="1.0" encoding="utf-8" ?>
16:51:47.905 ::*0000004* :: <soap:Envelope xmlns:soap="https://www.w3.org/2003/05/soap-envelope" xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="https://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsdp="https://schemas.xmlsoap.org/ws/2006/02/devprof" xmlns:un0="http://schemas.microsoft.com/windows/pnpx/2005/10" xmlns:pub="http://schemas.microsoft.com/windows/pub/2005/07"><soap:Header><wsa:To>https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsa:Action>https://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse</wsa:Action><wsa:MessageID>urn:uuid:2884cbcc-2848-4c35-9327-5ab5451a8729</wsa:MessageID><wsa:RelatesTo>urn:uuid:8506ac50-3646-4621-9680-86f484d87909</wsa:RelatesTo></soap:Header><soap:Body><wsx:Metadata><wsx:MetadataSection Dialect="https://schemas.xmlsoap.org/ws/2006/02/devprof/ThisDevice"><wsdp:ThisDevice><wsd
16:51:47.905 ::*0000004* :: <<<<-------- End ----------------------------------------------->>>>
Action 元素 (<wsa:Action>https://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse</wsa:Action>
) 将消息标识为 GetResponse 消息。 验证 GetResponse 消息的 RelatesTo 元素的值是否与 Get 消息的 MessageID 元素的值匹配。 在此示例中,RelatesTo 元素 (<wsa:RelatesTo>urn:uuid:8506ac50-3646-4621-9680-86f484d87909</wsa:RelatesTo>
) 的值与 Get 消息 (<wsa:MessageID>urn:uuid:8506ac50-3646-4621-9680-86f484d87909</wsa:MessageID>
) 的 MessageID 元素的值匹配。
相关主题