Actions:
Look Up Info:
Database Statistics Advanced:
Check Digit Calculator
|
XML-RPC Web ServiceThere is an XML-RPC web service located at the following URL:
Try the function 'help' for starters. Direct questions to the upcdb-dev mailing list. The API is VERY likely to change in the short term, so be warned. Note: This is NOT for your web browser. Don't expect to get any useful results from directing your web browser at this URL... More detail on how XML-RPC works is available at The XML-RPC Home Page. Here's a quick and dirty example of how to call this service in perl. Non-perl programmers would benefit from the debug output this generates.
#!/usr/local/bin/perl
use Frontier::Client;
use Data::Dumper;
use strict;
my $coder = Frontier::RPC2->new;
my $server = Frontier::Client->new( 'url' => 'http://dev.upcdatabase.com/rpc', debug => 1, );
my $method = shift;
my $result = $server->call($method, map { $coder->string($_) } @ARGV);
print Dumper($result);
__END__
Here's a chunk of Java code that calls the XML-RPC service:
import redstone.xmlrpc.XmlRpcClient;
import redstone.xmlrpc.XmlRpcStruct;
public static String getUPCText(String upc)
{
String text = "";
try
{
XmlRpcClient client = new XmlRpcClient( "http://www.upcdatabase.com/rpc", false);
XmlRpcStruct result = (XmlRpcStruct)client.invoke( "lookupUPC", new Object[] { upc } );
HashMap results = (HashMap)result;
if (
results.size()>0 &&
results.get("message").toString().equalsIgnoreCase("Database entry found"))
{
text = results.get("description").toString()+" "+results.get("size").toString();
}
}
catch (Exception e)
{
}
return text;
}
|