For your convenience, Logistech has provided an example Perl module which can be used to access our XML interface. We plan to keep it updated when we add new features, so it may be used in production, or you may use it as a reference for implementing your own XML code.

  Download the latest LSIxml.pm (last update 10/20/2009)

The file is well commented, but some examples of how to use it for some common tasks follow below.

A note on return values: most of the methods in the LSIxml perl library can return different type of objects depending on the results of the operation. See documentation in the LSIxml.pm file for a detailed description for each method.

Requirements

In order to use the LSIxml module, you will need the following packages installed if they are not already on your server :
  • libwww-perl (LWP)
  • URI::Escape
  • HTTP::Headers
  • XML::Simple
The required modules are available from CPAN.org.

Query Inventory

To query inventory, use the LSIxml::queryInventory method. Upon success, an LSIxml::Product object representing the results is returned. Here is an example, requesting inventory for product "XYZ-9999" :
  #!/usr/bin/perl
 
  use LSIxml;
 
  my $client_code = "TEST CLIENT CODE GIVEN TO YOU BY CSR";
  my $result = LSIxml::queryInventory($client_code, "XYZ-9999");
 
  # Success
  if (ref $result eq "LSIxml::Product") {
    print "In Stock : ".$result->in_stock."\n";
    print "On Order : ".$result->on_order."\n";
  # Error returned from LOMACS
  } elsif (ref $result eq "LSIxml::Error") {
    print "ERROR : ".$result->message."\n";
  # Error during transmission
  } else {
    print "ERROR : ".$result."\n";
  }

Place Orders

To place orders, the order objects must first be built up from your data. The LSIxml::Order class has methods that correspond to each field in the order schema that can be used to set values.

The order can then be submitted individually using the submit() method or several may be placed as a group using LSIxml::submitOrders() method. The following example is abbreviated to save space :
  #!/usr/bin/perl
 
  use LSIxml;
 
  my $client_code = "TEST CLIENT CODE GIVEN TO YOU BY CSR";
  my $profile_no = "TEST PROFILE GIVEN TO YOU BY CSR";
 
  my $order = new LSIxml::Order;
 
  $order->service("GND");
  $order->attn_name("John A. Doe");
  # ... more fields set here ...
 
  my $item = new LSIxml::Item("XYZ-9999", 1, "Widget Oil");
  $order->add_item($item);
  # ... more items added here ...
 
  # Submit orders
  my $result = LSIxml::submitOrders($client_code, $profile_no, $order);
 
  # A global error occurred
  if ($result) {
    print "ERROR : $result\n";
 
  # Check each order for success
  } else {
    if ($order->error) {
      print "ERROR: ".$order->errMsg."\n";
    } else {
      print "Success - LSI order ID is : ".$order->order_id."\n";
    }
  }

Tax/Shipping Query

To query tax/shipping charges, construct the orders as described above, and use the LSIxml::queryTaxShipping method :
  # Submit the query
  my $result = LSIxml::queryTaxShipping($client_code, $order);
  
  # A global error occurred
  if ($result) {
    print "ERROR : $result\n";
 
  # Check each order for success
  } else {
    if ($order->error) {
      print "ERROR: ".$order->errMsg."\n";
    } else {
      print "Success\n";
      my $ts_charge = $order->response;
      print "  Tax : ".$ts_charge->tax_charge."\n";
      print "  Shipping : ".$ts_charge->shipping_charge."\n";
      print "  Handling : ".$ts_charge->handling_charge."\n";
    }
  }