我想使用包含以下片段的XML请求调用XML-RPC Web服务的方法:
<member>
<name>filters</name>
<value><![CDATA[
<filterinstances>
<filterinstance type="date" comparison="equals">today</filterinstance>
</filterinstances>
]]></value>
</member>
为此,我使用XML-RPC.net代理,并将filters参数作为字符串传递:
IGetReportData proxy = XmlRpcProxyGen.Create<IGetReportData>();
proxy.Url = "<* my url >*";
proxy.KeepAlive = false;
proxy.UseStringTag = false;
ReportDataParams rp = new ReportDataParams();
rp.show = "3";
rp.filters = "<![CDATA[<filterinstances><filterinstance type=\"date\" comparison=\"equals\">today</filterinstance></filterinstances>]]>";
string s = proxy.GetReportData("test", rp);
ReportParams被定义为结构。
public struct ReportDataParams
{
public string show;
public string filters;
}
麻烦的是XML-RPC.Net在过滤器字符串中解码XML。以下片段将发送到服务器:
<member>
<name>filters</name>
<value>
<string><![CDATA[<filterinstances><filterinstance type="date" comparison="equals">today</filterinstance></filterinstances>]]></string>
</value>
</member>
有没有办法将CDATA xml片段作为参数传递给XML-RPC.Net?
答案 0 :(得分:0)
我遇到了类似的麻烦。我的解决方案就是撕掉所有CDATA的东西。在您的示例中,您只需传递:
<filterinstances><filterinstance type=\"date\" comparison=\"equals\">today</filterinstance></filterinstances>