我有一個Web服務,我打電話從C#。我已經能夠使用簡單的GET查詢,如成功獲得迴應:HTTP GET編碼Web服務調用
http://localhost:8080/cgi-bin/py-wps.cgi?service=wps&version=1.0.0&request=describeprocess&identifier=test
然而,當讓更復雜的查詢響應始終是一個錯誤。
http://localhost:8080/cgi-bin/py-wps.cgi?service=wps&version=1.0.0&request=execute&identifier=test&datainputs=[key1=val1,val2,val3;key2=val4;key3=val5]
我打電話的Web服務是使用PyWPS發佈的,而且我使用的查詢字符串在瀏覽器中有效。
我試圖逃避的鍵值對所有的值:
e.g. "datainputs=[key1="+Uri.EscapeDataString("val1"), ...
我也試過的
HttpUtility.UrlEncode
和
HttpUtility.UrlPathEncode
我的組合得到如下錯誤:異常exceptionCode =「MissingParameterValue」locator =「key1」
我不知道我在做什麼錯,但這些網址在我的瀏覽器中正常工作,所以我懷疑我編碼錯誤。我無法找到任何單個鍵值對包含鍵值對的列表(即datainputs = [key1 = v1,v2,v2; ...等)
在這個問題上的任何幫助,不勝感激。
編輯:這是我如何我打電話的web服務
var targetUri = new Uri(uri);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(targetUri);
req.Method = method.ToUpper();
req.ContentLength = 0;
req.ContentType = "text/xml";
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string responseString = reader.ReadToEnd();
reader.Close();
responseStream.Close();
response.Close();
return responseString;
第一種情況(第一個代碼塊)怎麼會不需要轉義,並且它可以正常工作。使用第二個代碼塊會拋出一個錯誤「 」。即使我逃避第二個查詢,我仍然會收到此錯誤。 –
Castrona
2012-01-04 21:59:17