Step-by-step guide to using the JAXWS SOAP APIs:

  1. The SOAP examples kit that is provided in the Enterprise and Business Edition KonaKart download kits (you can find them under the installation directory in a directory called java_soap_examples) contains everything you need to build a simple JAXWS SOAP client from the KonaKart Application WSDL. First verify that you have the kit in your version of KonaKart.

  2. Ensure that KonaKart has the JAXWS services enabled. See above for the ant targets to execute.

    Next, ensure that KonaKart is running on your machine. After the default installation you should be able to start KonaKart by clicking on the "Start KonaKart Server" start-up icon (on Windows) or by executing the {Konakart Home}/bin/startkonakart.sh script (on *nix). You need KonaKart to be running in order to get responses so your JAXWS SOAP calls that you will make with the examples.

  3. Check that the KonaKart server has started OK - a quick way would be to see if the application appears at http://localhost:8780/konakart

  4. Open up a console window and change directory to the location of the java_soap_examples, for example this would be:

    C:\> cd C:\KonaKart\java_soap_examples on Windows.

  5. Ensure that the environment variable JAVA_HOME is set correctly. On Windows, a suitable setting might be:

    JAVA_HOME=C:\jdk1.8.0_211

  6. Ensure that the JAVA_HOME/bin directory appears on your PATH. On Windows, this might look something like this:

    Path=C:\jdk1.8.0_211\bin;C:\WINDOWS\system32;C:\WINDOWS

    {You could also check that when you issue "java -version" you get the java version you expect}

  7. If you already have ANT installed, ANT_HOME is defined and ANT's bin directory is on your PATH you can skip the next two sections. If you don't have ANT installed you can use the cut-down version of ANT that we include in the KonaKart download kit, but you must set the following environment variables. Ensure that the environment variable ANT_HOME is set correctly in the command shell that you are executing (you probably don't want to change the environment variable globally). On Windows, if you installed KonaKart to the default location (C:\Program Files\KonaKart), it would be (note the slashes):

    ANT_HOME=C:/Program Files/KonaKart/custom/bin

  8. Ensure that the ANT_HOME/bin directory appears on your PATH. On Windows, this might look something like this:

    Path=C:\jdk1.8.0_211\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\KonaKart\custom\bin

    As a sanity check that you are set up ready to build the examples, check that you see the following when you issue a "ant -p" command:

    
    C:\KonaKart\java_soap_examples> ant -p
    Buildfile: C:\KonaKart\java_soap_examples\build.xml
    
    Main targets:
    
     build    Compiles and runs a little example
     clean    Clears away everything that's created during a build
     compile  Compile the examples
     run      Run the little example program
    Default target: build
    
    

    [The KonaKart download kit contains just enough of ANT for you to build the examples. For subsequent development using ANT you should consider installing a complete ANT installation - check the Apache ANT site for details]

  9. Simply execute the "ant" command to compile, then run, the simple SOAP example.

    If all is well you should see the following output:

    
    C:\KonaKart\java_soap_examples>..\custom\bin\ant
    Buildfile: C:\KonaKart\java_soap_examples\build.xml
    
    clean:
         [echo] Cleanup...
    
    compile:
    
    kktimestamp:
         [echo] Compile 8-October-2019 02:47:58.203
         [echo] Compile the examples
        [mkdir] Created dir: C:\KonaKart\java_soap_examples\classes
        [javac] Compiling 1 source file to C:\KonaKart\java_soap_examples\classes
    
    run:
    
    kktimestamp:
         [echo] Run 8-October-2019 02:47:59.515
         [java]
         [java] JAXWS SOAP Example...
         [java]
         [java] There are 244 countries
         [java] There are 25 manufacturers
         [java] The default currency is: USD
         [java] 63 products found
         [java] 63 length of product array
    
    build:
    
    BUILD SUCCESSFUL
    Total time: 7 seconds
    
    

    The code is very simple; here are a couple of extracts from SoapExample.java:

    
    EngineConfigIf engConfig = new EngineConfig();
    engConfig.setMode(EngineConfig.MODE_SINGLE_STORE);
                
    String kkEngClassName = "com.konakart.jws.KKJAXWSEng";          
    KKEngIf engine = new KKEngineUtils().getKKEngByName(kkEngClassName , engConfig);
    
    // make some example calls
    
    CountryIf[] countries = engine.getAllCountries();
    System.out.println("There are " + countries.length + " countries");
    
    ManufacturerIf[] manufacturers = engine.getAllManufacturers();
    System.out.println("There are " + manufacturers.length + " manufacturers");
    
    CurrencyIf curr = engine.getDefaultCurrency();
    System.out.println("The default currency is: " + curr.getCode());
    
    

    Notes:

    • If you've installed to a port other than 8780 and you will have to modify the konakart_jaxws_client.properties and konakartadmin_jaxws_client.properties file to define your JAXWS SOAP endpoint locations.

    • The files konakart_jaxws_client.properties and konakartadmin_jaxws_client.properties are used to define the locations of the respective web services. Therefore if these locations are not the default URLs you will need to modify these files as appropriate.

    • If you get "connection refused" - check that you have enabled JAXWS (see above ant commands), check your firewall isn't blocking your client calls and that the endpoints defined in the konakart_jaxws_client.properties and konakartadmin_jaxws_client.properties are actually responding correctly.