3

I'd like to call a method of a XML-RPC web service with a XML request containing the following fragment:

<member>
  <name>filters</name>
  <value><![CDATA[
    <filterinstances>
      <filterinstance type="date" comparison="equals">today</filterinstance>
    </filterinstances>
  ]]></value>
</member>    

To do this, I use a XML-RPC.net proxy and I pass the filters parameter as a string:

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);

The ReportParams is defined as a struct.

public struct ReportDataParams
{
    public string show;
    public string filters;
}

The trouble is that XML-RPC.Net decodes the XML within the filters string. The following fragment is sent to the server:

      <member>
        <name>filters</name>
        <value>
          <string>&lt;![CDATA[&lt;filterinstances&gt;&lt;filterinstance type="date" comparison="equals"&gt;today&lt;/filterinstance&gt;&lt;/filterinstances&gt;]]&gt;</string>
        </value>
      </member>

Is there any way to pass the CDATA xml fragment literally as a parameter to XML-RPC.Net?

Rudolf
  • 199
  • 8

1 Answers1

0

I had similar trouble. The solution for me was to just rip out all the CDATA stuff. In your example, you'd just pass:

<filterinstances><filterinstance type=\"date\" comparison=\"equals\">today</filterinstance></filterinstances>
Scott Decker
  • 4,229
  • 7
  • 24
  • 39
  • Thanks! Unfortunately, when I leave out the CDATA tag the call fails. This is because the xml data in the parameter is considered as a part of the xml request in that case. CDATA prevents that and passes the xml part as a literal. – Rudolf Apr 11 '14 at 12:19
  • @Rudolf if you have an example of a successful call, try using Fiddler and looking at what is actually getting sent across the wire. This helped me as well. – Scott Decker Apr 11 '14 at 13:41