• Welcome to KonaKart Community Forum. Please login or sign up.

SOAP and admin

Started by sdyck, April 21, 2009, 09:09:52 pm

Previous topic - Next topic


Hi, would anyone know why I always get null as my sessionID when calling KKWSAdminIf port.login(default,default)???  I was able to launch the Axis example fine but when I created a new test soap to insert a product into the db I keep getting this error:


java.rmi.RemoteException: Exception Message = The String parameter called sessionId (value=null) must be given a value. It cannot be set to null or be left empty.; nested exception is:
   com.konakartadmin.app.KKAdminException: Exception Message = The String parameter called sessionId (value=null) must be given a value. It cannot be set to null or be left empty.
   at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
   at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
   at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
   at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
   at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at com.konakartadmin.ws.KKWSAdminSoapBindingStub.insertProduct(KKWSAdminSoapBindingStub.java:7124)
   at com.konakart.InsertProduct.main(InsertProduct.java:144)


You will of course need a valid sessionId to be able to call many of the interfaces on the engines.

So, the obvious question is, are you using a valid username and password?


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)

           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
            // Image that will be used in the application for the product
            // Product model
            prod.setModel("test model");
            // Product price before applying tax
            prod.setPriceExTax(new BigDecimal(55.99));
            // Quantity of product in stock
            // Product status: 1=active, 0=inactive
            prod.setStatus((byte) 1);
            // The tax class of the product. Used to determine how much tax to apply.
            // 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.
            // Custom attribute. Can contain custom data.
            // Custom attribute. Can contain custom data.
            // Custom attribute. Can contain custom data.
            // Custom attribute. Can contain custom data.

             * 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].setName("Test Prod - E");
            descriptions[1] = new AdminProductDescription();
            descriptions[1].setDescription("Test prod - German");
            descriptions[1].setName("Test Prod - D");

             * 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
            AdminCategory[] catArray = new AdminCategory[1];
            catArray[0] = cat;

             * 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)
            // This points to the option value in the products_options_values table with id = 1 (4MB
            // in demo DB)
            // This option costs an extra 20 if selected
            prodAttr1.setPrice(new BigDecimal(20));
            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)
            // This points to the option value in the products_options_values table with id = 5
            // (Value model
            // in demo DB)
            // The product price is reduced by 10 if this option is selected
            prodAttr2.setPrice(new BigDecimal(10));
            attrs[1] = prodAttr2;

            // Add the attributes to the product
            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.
            } else
                System.out.println("The product could not be read from the DB");

        } catch (Exception e)




err .. btw I am passing sessionId to the int prodId = port.insertProduct(sessionId, prod); call


Found it ... I was using the default url that is generated from the wsdl, changed it to use my local and all's good