我試圖通過以下XML文本RIA服務在響應返回實體的可查詢序列的查詢操作傳遞XML文本RIA服務:麻煩從我的客戶
<?xml version="1.0" encoding="utf-8"?>
<project>
<item type="Item" filetype="cabinet" category="EZ Workshop" name="EZW Panel Edge-Banded" height="24.000000" width="36.000000" depth="0.725000" quantity="1">
</item>
<item type="Item" filetype="cabinet" category="EZ Furniture" name="Entry Bench" height="19.000000" width="48.000000" depth="17.999999" quantity="1">
</item>
<item type="Item" filetype="cabinet" category="EZ Closet Euro Style" name="CSEKD Tall H3R 28-72W 12-24D" height="84.000000" width="54.000000" depth="19.999999" quantity="1">
</item>
<item type="Item" filetype="assembly" category="EZ Pro ManCave" name="EZ Corn Hole Game-Set" height="0" width="0" depth="0" quantity="1">
</item>
<item type="Item" filetype="assembly" category="EZ Office" name="EZ 30 Printer Stand" height="0" width="0" depth="0" quantity="1">
</item>
<item type="Item" filetype="assembly" category="Corporate Culture Pro" name="C-Table" height="0" width="0" depth="0" quantity="1">
</item>
</project>
這是查詢操作:
[Query]
public IQueryable<ProjectItem> GetItemsFromImport(String a_strImportXml)
{
// Return empty sequence for now as a test.
return new ProjectItem[0].AsQueryable();
}
當我通過完整的XML時,我得到了令人討厭的「未找到」異常,並且我的操作中的斷點從未被命中。我正在使用Visual Studio 2010的ASP.NET開發服務器。當我得到「未找到」,因爲它預示不好的東西。踢球者是,當我傳遞一個空字符串時,我根本沒有任何例外,並且擊中了斷點。
正如你可以看到它不是一個巨大的XML文檔。發送的數據量有限制嗎?我必須逃離文件嗎?
謝謝。
編輯:
我發現我只有逃避結構特徵(「<」,‘>’和「&」)從文件之前我把它。我使用String.Replace
來做到這一點。有誰知道是否有更好的方法來實現這一點。或許類似於Uri.EscapeDataString
?
var strImportXml = a_xImport.ToString();
strImportXml = strImportXml.Replace("&", "&");
strImportXml = strImportXml.Replace("<", "<");
strImportXml = strImportXml.Replace(">", ">");