.NET MVC 4.5 in C# xml-rpc.net library from Charles Cook
Trying to hit a 3rd party vendor with xml-rpc. I need to send them some xml formatted like the following:
<?xml version='1.0' encoding='iso-8859-1'?>
<QuoteRequest>
<User_ID>XXXXXXXX</User_ID>
<State>AL</State>
<Zip_Code>35201</Zip_Code>
<Applicant_Gender>Male</Applicant_Gender>
<Applicant_Age>30</Applicant_Age>
<Plan_ID>10</Plan_ID>
</QuoteRequest>
My efforts thus far:
var quoteRequest = new XmlRpcStruct();
var quoteRequestSpecs = new XmlRpcStruct();
quoteRequestSpecs.Add("Plan_ID", "10");
//add in other bits of xml here...user id, state, zip code, etc
quoteRequest.Add("QuoteRequest", quoteRequestSpecs);
var proxy = XmlRpcProxyGen.Create<IQuoteRequest>();
proxy.Url = "http://myfakeurl.com"
var response = proxy.QuoteRequest(quoteRequest);
and the IQuoteRequest looks like the following:
public interface IQuoteRequest : IXmlRpcProxy
{
[XmlRpcMethod("QuoteRequest")]
string QuoteRequest(XmlRpcStruct request);
}
I hit the service fine, but all I get back is the following:
"<?xml version="1.0" encoding="iso-8859-1"?><QuoteResult><Error><Message>Incorrect Plan ID.#</Message></Error></QuoteResult>"
Important part: "Incorrect Plan ID".
Yes, I know I'm using the correct plan ID.
I get the same message if I attach no information at all and just send across an empty XmlRpcStruct, so I don't think my data is getting sent.
Ended up just needing to pass a string, not actual xml.
var quoteRequest = "<QuoteRequest><User_ID>XXXXXXXXX</User_ID><State>TX</State><Zip_Code>75251</Zip_Code><Applicant_Gender>Male</Applicant_Gender><Plan_ID>10</Plan_ID></QuoteRequest>";
var proxy = XmlRpcProxyGen.Create<IQuoteRequest>();
proxy.Url = "http://myfakeurl.com"
var response = proxy.QuoteRequest(quoteRequest);
and IQuoteRequest looks like:
public interface IQuoteRequest : IXmlRpcProxy
{
[XmlRpcMethod("QuoteRequest")]
string QuoteRequest(string request);
}