开发者

C# - xml-rpc with a single method and 2 named param

This is a refined and focused question that I asked last week about a project I am working on to use the web service http://www.upcdatabase.com via xml-rpc .net. I am working in c#. The request requires a named method (“lookup”) as well as 2 named parameters (“rpc_key”) and (“upc”), both types are stings. My initial thought was to create an interface like this:

[XmlRpcUrl("http://www.upcdatabase.com/xmlrpc")]
   public interface UPChelp : IXmlRpcProxy
  [XmlRpcMethod("lookup")]
  upcLookupValues lookupUPC(string rpc_key, string upc);

upcLookupValues is a struct that is returned defined as:
public struct upcLookupValues
    {
        public string upc;
        public int pendingUpdates;
        public string status;
        public string ean;         
        public string issureCountryCode;
        public bool found;
        public string description;
        public string message;
        public string size;
        public string issureCountry;
        public string noCacheAfterUTC;
        public string lastModifiedUTC;
    }

The proxy generation I have been working with is

UPChelp upcObj = XmlRpcProxyGen.Create<UPChelp>();
upcLookupValues myLookup = upcObj.lookupUPC("000000000000000000000000000000000000000000”, "639382000393");

I get a response of invalid parameters.. So while reading the xml-rpc faq I came across:

“2.20 How do I call an XML-RPC method with a variable number of parameters? The params keyword can be used to call an XML-RPC method which take a variable number of parameters. For example, if an XML-RPC method takes a variable number number of integer parameters it could be defined like this: [XmlRpcUrl("http://www.cookcomputing.com/notimpl.rem")] public interface IParams : IXmlRpcProxy { [XmlRpcMethod]

int UseNumbers(params int[] numbers); } And called like this: IFoo proxy = (IFoo)XmlRpcProxyGen.Create(typeof(IFoo)); proxy.SendMultipleParameters(1); proxy.SendMultipleParameters(1, 2, 3);”

Alternatively the parameters in this example can be supplied as an array of type int[]: in开发者_运维百科t[] parameters = new int[] { 1, 2, 3 }; proxy.SendMultipleParameters(parameters);"

My problem is I don’t understand how to apply this concept to my project, (I am a newbie), I tried upcLookupValues[] parameters = new string[] { "rpc_key", "upc" }; But I get a cant implicitly convert string[] to readUPC.upcLookupvalues[]. I also don’t understand how to define the new proxy for submission. My fingers are crossed this post makes sense. I am sure you C# xml-rpc folks are laughing right now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜