Yes of course I am .... below is the source to my InsertProduct.java I am using to test ... I used the wsdl from web to generate the proxy classes:
package com.konakart;
import java.math.BigDecimal;
import java.util.Date;
import com.konakartadmin.app.AdminCategory;
import com.konakartadmin.app.AdminProduct;
import com.konakartadmin.app.AdminProductAttribute;
import com.konakartadmin.app.AdminProductDescription;
import com.konakartadmin.ws.KKWSAdminIf;
import com.konakartadmin.ws.KKWSAdminIfServiceLocator;
public class InsertProduct{
private static String DEFAULT_USERNAME = "admin@konakart.com";
private static String DEFAULT_PASSWORD = "princess";
public InsertProduct(){
}
/**
* @param args
*/
public static void main(String[] args)
{
try
{
KKWSAdminIf port = new KKWSAdminIfServiceLocator().getKKWSAdmin();
/*
* Instantiate an AdminProduct object and set some of its attributes
*/
AdminProduct prod = new AdminProduct();
// Assuming we have a manufacturer in the DB with id==1
prod.setManufacturerId(1);
// Image that will be used in the application for the product
prod.setImage("test/test.gif");
// Product model
prod.setModel("test model");
// Product price before applying tax
prod.setPriceExTax(new BigDecimal(55.99));
// Quantity of product in stock
prod.setQuantity(20);
// Product status: 1=active, 0=inactive
prod.setStatus((byte) 1);
// The tax class of the product. Used to determine how much tax to apply.
prod.setTaxClassId(1);
// Weight of product. Can be used to calculate shipping cost.
prod.setWeight(new BigDecimal(5));
// Defines when the product will be available
//prod.setDateAvailable(new Date());
// Custom attribute. Can contain custom data.
prod.setCustom1("custom1");
// Custom attribute. Can contain custom data.
prod.setCustom2("custom2");
// Custom attribute. Can contain custom data.
prod.setCustom3("custom3");
// Custom attribute. Can contain custom data.
prod.setCustom4("custom4");
// Custom attribute. Can contain custom data.
prod.setCustom5("custom5");
/*
* An Admin Product object has an array of AdminProductDescription objects, each one of
* which contains a name, description and url for a different language. The url is
* language dependent since it can point to the home page of the product for the country
* in question.
*/
AdminProductDescription[] descriptions = new AdminProductDescription[2];
descriptions[0] = new AdminProductDescription();
descriptions[0].setDescription("Test prod - English");
descriptions[0].setLanguageId(1);
descriptions[0].setName("Test Prod - E");
descriptions[0].setUrl("www.testprod.co.uk");
descriptions[1] = new AdminProductDescription();
descriptions[1].setDescription("Test prod - German");
descriptions[1].setLanguageId(2);
descriptions[1].setName("Test Prod - D");
descriptions[1].setUrl("www.testprod.de");
prod.setDescriptions(descriptions);
/*
* An Admin Product may belong to one or more categories. We create an array of
* categories and add one category to the array which we then add to the product.
*/
AdminCategory cat = new AdminCategory();
// Assuming we have a category with id==1 in the database
cat.setId(1);
AdminCategory[] catArray = new AdminCategory[1];
catArray[0] = cat;
prod.setCategories(catArray);
/*
* The following Admin Product Attributes are optional. They are used if the product has
* options which can be selected to configure the product. These options may add or
* subtract a value from the final price. i.e. Size "extra small" may be -$10.00 from
* the product price while size "extra large" may be +$10.00.
*/
// We will add two attributes
AdminProductAttribute[] attrs = new AdminProductAttribute[2];
// Attribute 1
AdminProductAttribute prodAttr1 = new AdminProductAttribute();
// This points to the option in the products_options table with id = 4 (Memory in demo
// DB)
prodAttr1.setOptionId(4);
// This points to the option value in the products_options_values table with id = 1 (4MB
// in demo DB)
prodAttr1.setOptionValueId(1);
// This option costs an extra 20 if selected
prodAttr1.setPrice(new BigDecimal(20));
prodAttr1.setPricePrefix("+");
attrs[0] = prodAttr1;
// Attribute 2
AdminProductAttribute prodAttr2 = new AdminProductAttribute();
// This points to the option in the products_options table with id = 3 (Model in demo
// DB)
prodAttr2.setOptionId(3);
// This points to the option value in the products_options_values table with id = 5
// (Value model
// in demo DB)
prodAttr2.setOptionValueId(5);
// The product price is reduced by 10 if this option is selected
prodAttr2.setPrice(new BigDecimal(10));
prodAttr2.setPricePrefix("-");
attrs[1] = prodAttr2;
// Add the attributes to the product
prod.setAttributes(attrs);
String sessionId = port.login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
// Insert the product and get the product Id
int prodId = port.insertProduct(null, prod);
System.out.println("Product Id of inserted product = " + prodId);
// Read the product from the database
prod = port.getProduct(sessionId, prodId);
if (prod != null)
{
/*
* Note that the name and description of the admin product object are set to null
* because they are in the AdminProductDescription array for each language. If the
* same product is read through the KonaKart application API, the name and
* description will be set to the values defined by the chosen language.
*/
System.out.println(prod.toString());
} else
{
System.out.println("The product could not be read from the DB");
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
package com.konakart;
import java.math.BigDecimal;
import java.util.Date;
import com.konakartadmin.app.AdminCategory;
import com.konakartadmin.app.AdminProduct;
import com.konakartadmin.app.AdminProductAttribute;
import com.konakartadmin.app.AdminProductDescription;
import com.konakartadmin.ws.KKWSAdminIf;
import com.konakartadmin.ws.KKWSAdminIfServiceLocator;
public class InsertProduct{
private static String DEFAULT_USERNAME = "admin@konakart.com";
private static String DEFAULT_PASSWORD = "princess";
public InsertProduct(){
}
/**
* @param args
*/
public static void main(String[] args)
{
try
{
KKWSAdminIf port = new KKWSAdminIfServiceLocator().getKKWSAdmin();
/*
* Instantiate an AdminProduct object and set some of its attributes
*/
AdminProduct prod = new AdminProduct();
// Assuming we have a manufacturer in the DB with id==1
prod.setManufacturerId(1);
// Image that will be used in the application for the product
prod.setImage("test/test.gif");
// Product model
prod.setModel("test model");
// Product price before applying tax
prod.setPriceExTax(new BigDecimal(55.99));
// Quantity of product in stock
prod.setQuantity(20);
// Product status: 1=active, 0=inactive
prod.setStatus((byte) 1);
// The tax class of the product. Used to determine how much tax to apply.
prod.setTaxClassId(1);
// Weight of product. Can be used to calculate shipping cost.
prod.setWeight(new BigDecimal(5));
// Defines when the product will be available
//prod.setDateAvailable(new Date());
// Custom attribute. Can contain custom data.
prod.setCustom1("custom1");
// Custom attribute. Can contain custom data.
prod.setCustom2("custom2");
// Custom attribute. Can contain custom data.
prod.setCustom3("custom3");
// Custom attribute. Can contain custom data.
prod.setCustom4("custom4");
// Custom attribute. Can contain custom data.
prod.setCustom5("custom5");
/*
* An Admin Product object has an array of AdminProductDescription objects, each one of
* which contains a name, description and url for a different language. The url is
* language dependent since it can point to the home page of the product for the country
* in question.
*/
AdminProductDescription[] descriptions = new AdminProductDescription[2];
descriptions[0] = new AdminProductDescription();
descriptions[0].setDescription("Test prod - English");
descriptions[0].setLanguageId(1);
descriptions[0].setName("Test Prod - E");
descriptions[0].setUrl("www.testprod.co.uk");
descriptions[1] = new AdminProductDescription();
descriptions[1].setDescription("Test prod - German");
descriptions[1].setLanguageId(2);
descriptions[1].setName("Test Prod - D");
descriptions[1].setUrl("www.testprod.de");
prod.setDescriptions(descriptions);
/*
* An Admin Product may belong to one or more categories. We create an array of
* categories and add one category to the array which we then add to the product.
*/
AdminCategory cat = new AdminCategory();
// Assuming we have a category with id==1 in the database
cat.setId(1);
AdminCategory[] catArray = new AdminCategory[1];
catArray[0] = cat;
prod.setCategories(catArray);
/*
* The following Admin Product Attributes are optional. They are used if the product has
* options which can be selected to configure the product. These options may add or
* subtract a value from the final price. i.e. Size "extra small" may be -$10.00 from
* the product price while size "extra large" may be +$10.00.
*/
// We will add two attributes
AdminProductAttribute[] attrs = new AdminProductAttribute[2];
// Attribute 1
AdminProductAttribute prodAttr1 = new AdminProductAttribute();
// This points to the option in the products_options table with id = 4 (Memory in demo
// DB)
prodAttr1.setOptionId(4);
// This points to the option value in the products_options_values table with id = 1 (4MB
// in demo DB)
prodAttr1.setOptionValueId(1);
// This option costs an extra 20 if selected
prodAttr1.setPrice(new BigDecimal(20));
prodAttr1.setPricePrefix("+");
attrs[0] = prodAttr1;
// Attribute 2
AdminProductAttribute prodAttr2 = new AdminProductAttribute();
// This points to the option in the products_options table with id = 3 (Model in demo
// DB)
prodAttr2.setOptionId(3);
// This points to the option value in the products_options_values table with id = 5
// (Value model
// in demo DB)
prodAttr2.setOptionValueId(5);
// The product price is reduced by 10 if this option is selected
prodAttr2.setPrice(new BigDecimal(10));
prodAttr2.setPricePrefix("-");
attrs[1] = prodAttr2;
// Add the attributes to the product
prod.setAttributes(attrs);
String sessionId = port.login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
// Insert the product and get the product Id
int prodId = port.insertProduct(null, prod);
System.out.println("Product Id of inserted product = " + prodId);
// Read the product from the database
prod = port.getProduct(sessionId, prodId);
if (prod != null)
{
/*
* Note that the name and description of the admin product object are set to null
* because they are in the AdminProductDescription array for each language. If the
* same product is read through the KonaKart application API, the name and
* description will be set to the values defined by the chosen language.
*/
System.out.println(prod.toString());
} else
{
System.out.println("The product could not be read from the DB");
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}