using System; using System.Collections.Generic; using System.Text; using CookComputing.XmlRpc; using System.Xml; namespace KitchenInventory //can you guess what my software does lol... { [XmlRpcMissingMapping(MappingAction.Ignore)] //the above line keeps missing members from casuising an error, more info at www.xml-rpc.net // I noticed many records don’t have the mfr_comment data, so the member is NOT returned in the xml. // // youll still need to deal with the missing data, but at least your // rpc call will work, FYI: Use the Internet Exploere "Fidiler add in" // to veiw returned data when you make a rpc call… very handy public struct upcLookupValues { public string upc; public int pendingUpdates; public bool isCoupon; public string ean; public string issureCountryCode; public string mfr_comment; public string mfr; public string description; public bool found; public string size; public string message; public string issureCountry; public string lastModified; } [XmlRpcUrl("https://www.upcdatabase.com/rpc")] public interface IgetHelp : IXmlRpcProxy { [XmlRpcMethod("help")] string upcHelp(); } [XmlRpcUrl("https://www.upcdatabase.com/rpc")] public interface IlookupUPC : IXmlRpcProxy { [XmlRpcMethod("lookupUPC")] upcLookupValues lookupUPC(string upcCode); } [XmlRpcUrl("https://www.upcdatabase.com/rpc")] public interface IlookupEAN : IXmlRpcProxy { [XmlRpcMethod("lookupEAN")] upcLookupValues lookupEAN(string EANCode); } [XmlRpcUrl("https://www.upcdatabase.com/rpc")] public interface IconvertUPCE : IXmlRpcProxy { [XmlRpcMethod("convertUPCE")] string convertUPCE(string upcCode); } class lookupUPC { public static string getHelp() { //calls the upcdatabase.com xml server with the help paramaters, returns as string with the help... IgetHelp upcObj = XmlRpcProxyGen.Create(); string myLookup = upcObj.upcHelp(); return myLookup; } public static string convertUPCE(string upce_code) { //cals the upce_convert method, and returns the ean string… IconvertUPCE upcObj = XmlRpcProxyGen.Create(); //turn off the xmlRpcProxy keep alive, // fixes the The underlying connection was closed: An unexpected error occurred on a send. upcObj.KeepAlive = false; string myLookup = upcObj.convertUPCE(upce_code); return myLookup; } public static upcLookupValues lookupBarCode(string barCode) { string myEan; upcLookupValues myOutput; switch (barCode.Length) { case 12: myOutput = getEan("0"+ barCode); break; case 8: myEan = convertUPCE(barCode); myOutput = getEan(myEan); break; default: myOutput = getEan(barCode); break; } myOutput.upc = barCode; return myOutput; } public static upcLookupValues getEan(string eanCode) { IlookupEAN upcObj = XmlRpcProxyGen.Create(); //turn off the xmlRpcProxy keep alive, // fixes the The underlying connection was closed: An unexpected error occurred on a send. upcObj.KeepAlive = false; //phone 821793000080 upcLookupValues upcOutput = upcObj.lookupEAN(eanCode); return upcOutput; } public static upcLookupValues getUpc(string upcCode) { //this method depricated, but still works, I now padd a 0 on the begging of the UPCA code and use getEAN method IlookupUPC upcObj = XmlRpcProxyGen.Create(); //turn off the xmlRpcProxy keep alive, // fixes the The underlying connection was closed: An unexpected error occurred on a send. upcObj.KeepAlive = false; upcLookupValues upcOutput = upcObj.lookupUPC(upcCode); return upcOutput; } } }