クエリ可能なエンティティのシーケンスを応答で返すクエリ操作で、次の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を渡すと、その厄介な「見つかりません」例外が発生し、操作のブレークポイントに到達することはありません。VisualStudio2010のASP.NET開発サーバーを使用しています。それで「見つかりません」となると、それは悪いことの前兆です。キッカーは、空の文字列を渡すと、例外がまったく発生せず、ブレークポイントに到達することです。
ご覧のとおり、それほど長くないXMLドキュメントです。送信するデータ量に制限はありますか?ドキュメントをエスケープする必要がありますか?
ありがとう。
編集:
送信する前に、ドキュメントから構造文字('<'、'>'、および'&')をエスケープするだけでよいことがわかりました。私はそれをするために使用String.Replace
しています。これを達成するためのより良い方法があるかどうか誰かが知っていますか?Uri.EscapeDataString
おそらく似たようなものですか?
var strImportXml = a_xImport.ToString();
strImportXml = strImportXml.Replace("&", "&");
strImportXml = strImportXml.Replace("<", "<");
strImportXml = strImportXml.Replace(">", ">");