Setting up a new project

To create a minimal project with one API containing one function, you need 3 files :

xins-project.xml

  • Create a new directory where your APIs based on XINS will be created. For example c:\projects.

  • Create a new xins-project.xml file in this directory with the content :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE project PUBLIC "-//XINS//DTD XINS Project 2.2//EN"
              "http://www.xins.org/dtd/xins-project_2_2.dtd">
    <project name="myprojects"
             rcsversion="$Revision$" rcsdate="$Date$"
             domain="com.mycompany">
    </project>

api.xml

To create a new api.xml execute in the projects directory xins create-api.

The command will ask you for the name and the description of your api. The script will then create a new api.xml file in the directory apis\<api name>\spec with the content :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE api PUBLIC "-//XINS//DTD XINS API 2.2//EN"
          "http://www.xins.org/dtd/api_2_2.dtd">

<api name="myproject" rcsversion="$Revision$" rcsdate="$Date$">

  <description>Description of the API.</description>

</api>

Then the command will ask you if you want to create an implementation of the api. This will create the skeleton java file where you will write the code of your function. If you answer yes, a new file impl.xml is created in the apis\<api name>\impl directory with the content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE impl PUBLIC "-//XINS//DTD Implementation 2.2//EN"
          "http://www.xins.org/dtd/impl_2_2.dtd">

<impl>
</impl>

Finally the command will ask you if you want to define some environments with your api. If you answer yes, a new file environments.xml is created in the apis\<api name> directory with the content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE environments PUBLIC "-//XINS//DTD Environments 2.2//EN"
          "http://www.xins.org/dtd/environments_2_2.dtd">

<environments>

  <environment id="localhost" url="http://127.0.0.1:8080/myproject/" />

</environments>

Note

In this guide we will use the xins command to create the different files of the project, but it is also possible to do it manually using a text editor.

If you created the file manually, add the line <api name="myproject"/> in the xins-project.xml file. If the API has an implementation, add the element <impl/> in the <api> element and if it defines some environments add <environments/> in <api>.

MyFunction.fnc

Now that you've created the API definition, we need to define a function within this API.

To create a new function execute xins create-function.

The command will ask you for the name of your api and the name and the description of your function. The script will then create a new <function name>.fnc file in the directory apis/<api name>/spec with the content :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE function PUBLIC "-//XINS//DTD Function 2.2//EN"
          "http://www.xins.org/dtd/function_2_2.dtd">

<function name="MyFunction" rcsversion="$Revision$" rcsdate="$Date$">

  <description>Description of the function.</description>

</function>

If the file was created without calling the create-function target, add the line <function name="MyFunction"/> in the api.xml file.