問題如下:
我想使用get與body來使用RESTful服務。出於測試目的,我使用Fiddler Web Debugger。
現在,下面的GET請求投入提琴手得到我的結果,我期待:
GET http://localhost:3787/TerminologyService/Autosuggest/ HTTP/1.1
Host: localhost:3787
Content-Length: 215
Content-Type: application/json
{
"Text": "war",
"Count": "100",
"MedicationWeight": "7",
"ActivityWeight": "0",
"DiseaseWeight": "0",
"GeneWeight": "0",
"SymptomWeight": "0",
"AnatomyWeight": "0",
"OrderingType": "CATEGORY_DIVERSITY"
}
所以,現在我使用$ http.get做同樣的事情。 這裏是我到目前爲止有:
function getTerms(text, count, medWeight, actWeight, disWeight, genWeight, symWeight, anaWeight, orderingType)
{
var config = {
headers: {'Content-Type' : 'application/json'},
params: {Text : text,
Count : count,
MedicationWeight : medWeight,
ActivityWeight : actWeight,
DiseaseWeight : disWeight,
GeneWeight : genWeight,
SymptomWeight : symWeight,
AnatomyWeight : anaWeight,
OrderingType : orderingType}
}
return $http.get(
'http://localhost:3787/TerminologyService/Autosuggest', config);
}
這並獲得形成一個GET網址:
http://localhost:3787/TerminologyService/Autosuggest?ActivityWeight=0&AnatomyWeight=0&Count=10&DiseaseWeight=0&GeneWeight=0&MedicationWeight=7&OrderingType=CATEGORY_DIVERSITY&SymptomWeight=0&Text=war
不幸的是,這會導致錯誤500的web服務。
當我檢查由$ http.get調用生成的Fiddler中捕獲的流量時,我發現JSON數據沒有作爲正文傳遞(顯然,因爲它是通過URL傳遞的)。所以我沒能得到什麼,我第一次在提琴手
任何幫助深表感謝
500指在服務器上發生的錯誤side..you應調試代碼在服務器.. –
是發生的原因是未如預期形成錯誤的請求通過web服務。我無法通過GET機構,因爲我在我的提琴手測試中。 –
獲取請求確實只通過URL傳遞所有參數。 –