2014-09-29 56 views
-1

我正在處理這個服務器端的asp腳本。它應該從一個web應用程序接收一個xml流並將其保存在一個xml文件中。問題是我一直無法讀取這個流。我使用了不同的方法,但似乎找不到合適的方法。另一件事是測試我使用休息控制檯添加鉻,它似乎工作沒有問題,但是當我的客戶端發送流我無法閱讀它,他們收到代碼500錯誤。從httprequest檢索數據

起初我試圖讀取二進制模式流,然後將其轉換

function readContent() 
    dim a,b 
    a=Request.TotalBytes 
    b=Request.BinaryRead(a) 
    writeInLogFile(" ") 
    writeInLogFile(Time & Request.ServerVariables("ALL_RAW")) 
    writeInLogFile(Time & " Data read in binary mode with a size of " & a) 
    readContent = URLDecode(BytesToStr(b)) 
    writeInLogFile(Time & " the length of the converted string is : "& len(readContent)) 
end function 

但這裏是我一直讓我的日誌文件

17:12:10Content-Length: 8416 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
Authorization: Basic 
Host: 
User-Agent: Jakarta Commons-HttpClient/2.0.2 

17:12:10 Data read in binary mode with a size of 8416 

17:12:10 Converting binary to string

,然後當我嘗試寫崩潰轉換的字符串

然後我切換到request.form

function readContent() 
    'writeInLogFile(Time & " " & URLDecode(Request.Form)) 
    writeInLogFile(Time & Request.ServerVariables("ALL_RAW")) 
    readContent = URLDecode(Request.Form) 
    writeInLogFile(Time & " the length of the converted string is : "& len(readContent)) 
end function 

但仍然通過休息控制檯測試時,所有工作和實際接收來自我的客戶端的流只是崩潰。

任何人都面臨着類似的問題,或有一個想法,我怎麼能解決這個事情提前

感謝

更新:

這裏是解碼功能

FUNCTION URLDecode(str) 
    '// This function: 
    '// - decodes any utf-8 encoded characters into unicode characters eg. (%C3%A5 = å) 
    '// - replaces any plus sign separators with a space character 
    '// 
    '// IMPORTANT: 
    '// Your webpage must use the UTF-8 character set. Easiest method is to use this META tag: 
    '// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    '// 
    Dim objScript 
    Set objScript = Server.CreateObject("ScriptControl") 
    objScript.Language = "JavaScript" 
    URLDecode = objScript.Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))") 
    Set objScript = NOTHING 
    'writeInLogFile(Time & " the length of the converted string is : "& len(URLDecode)) 
END FUNCTION 
+0

您缺少相關代碼,這兩個函數的來源是什麼樣的? 'URLDecode(BytesToStr(b)中)'。但看看你在做什麼,我會說這個問題是在'URLDecode()'函數中。 – Lankymart 2014-09-29 09:45:27

+0

不,在URLDecode()函數中沒有錯誤,就像我在本地測試(Rest控制檯)時所說的,一切運行平穩,並且功能完美。 – bibo 2014-09-29 12:05:40

+0

猜猜這沒有問題,那麼你顯然知道你在做什麼。祝你好運。 – Lankymart 2014-09-29 13:51:16

回答

0

客戶端表示將發送的編碼與流實際發送的編碼不同。

Request.Form就是答案。