使用 WinHTTP 記錄來驗證取得流量
如果泛型主機和用戶端成功,但實際的主機和用戶端仍然失敗,則元數據要求可能尚未起始。 WinHTTP 記錄可用來驗證輸出訊息是否已產生並正確傳送。
WSDAPI 型用戶端應用程式會使用 WinHTTP 連線到裝置。 WSDAPI 型裝置主機不使用 WinHTTP。 此外,某些第三方 Proxy 不會使用 WinHTTP。 針對不使用 WinHTTP 的伺服器或代理伺服器進行疑難排解時,請略過此診斷程式,再依 檢查 HTTP 元數據交換的網路追蹤中的程式繼續疑難排解。
WinHTTP 記錄不會顯示所有 TCP 層級流量。 略過 檢查 HTTP 元數據交換的網路追蹤,若對於除 HTTP 流量以外的其他流量感興趣,請參考。
使用 WinHTTP 日誌來驗證獲取的流量
- 擷取 WinHTTP 記錄。
- 啟動 [記事本] 或其他文字編輯器。 文本編輯器必須以系統管理員身分執行。
- 開啟 WinHTTP 記錄檔。
- 確認已傳送必要的 HTTP 要求和元數據訊息。
如果在 WinHTTP 記錄中找到主機的 取得 訊息,則會成功將元數據要求傳送至 WinHTTP。 請遵循 檢查 HTTP 元數據 Exchange 的網路追蹤中的程式,繼續進行疑難解答。
如果在 WinHTTP 記錄中找不到主機的 Get 訊息,則無法啟動元數據請求。 當主機發佈無效的 XAddrs 時,就會發生這種情況。 確認主機上的 XAddrs 符合 XAddr 驗證規則。
成功交換元數據時,必須發生下列事件:
- 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>
)將此訊息識別為 取得 訊息。 確認 To 元素的值(例如,<wsa:To>urn:uuid:dbe17c74-3b21-4f52-addc-b84b444f73a0</wsa:To>
)符合主機在原始 UDP WS-Discovery 訊息中公告的裝置標識碼。 您可以使用 WSD 偵錯主機來檢查主機公告的裝置識別碼。 如需更多資訊,請參閱 使用通用主機和客戶端來執行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 訊息的 MessageID 元素的值(<wsa:MessageID>urn:uuid:8506ac50-3646-4621-9680-86f484d87909</wsa:MessageID>
)相符。