Source Code
The first thing to do to write a web service using the controller codes is to create the controller class through the Controller Code Generation button on the JGuarClient screen. This button is pressed to create the Controller class, and then the corresponding browser is opened in the menu tree. In this browser, the new button is pressed. After this process, the relevant fields are filled in the data entry form and the form is saved. The only thing to remember is that after saving the data entry form the browser has to be closed. Finally, at the very beginning of the process, the Controller Code Generation button, which is printed at the beginning of the process, is pressed again to save the generated controller class.
Below is the steps for transferring a material with the web service using the controller class of a material creation process.
- The Controller Code Generation key is pressed on the JGuarClient screen.
- The Material Browser opens under the Materials Management module in the menu tree.
- Click on the Commodity from the menu button (TM) on the Browser.
- Enter the data to be saved in the opened material form and press the save button.
- The material is closed by pressing the close button on the browser.
- Finally, the generated controller class is recorded by pressing the Controller Code Generation button.
The generated controller class will have the following structure.
package com.acme.customization;
import com.lbs.controllers.ILbsControllerTask;
import com.lbs.controllers.menu.LbsMenuController;
import com.lbs.remoteclient.IClientContext;
import com.lbs.control.interfaces.ILbsController;
import com.lbs.controllers.gen.mm.MMXFItemBrowserController;
import com.lbs.controllers.gen.mm.MMXFItemController;
import java.math.BigDecimal;
public class ItemControllerWebService implements ILbsControllerTask
{
public void execute(LbsMenuController menu, IClientContext context)
{
try
{
ILbsController controller = menu.launchMaterials();
if (controller instanceof MMXFItemBrowserController)
{
MMXFItemBrowserController controller1 = (MMXFItemBrowserController) controller;
controller = controller1.createNew_CGCommercialGood();
if (controller instanceof MMXFItemController)
{
MMXFItemController controller2 = (MMXFItemController) controller;
controller2.setDescription("Malzeme açıklaması");
controller2.setSearchText("Arama Metni");
controller2.setAuxCode("ÖZEL KOD");
controller2.setAuthCode("YETKİ KODU");
controller2.setShelfLife(new BigDecimal(10.0));
controller2.selectComboBoxShelfLife_Week();
controller2.setGuaranteePeriod(new BigDecimal(2.0));
controller2.selectComboBoxGuaranteePeriod_Year();
controller2.setAverageIn_StockDuration_day(new BigDecimal(30.0));
controller2.selectComboBoxCostingMethod1_FIFO();
controller2.selectComboBoxCostingMethod2_LIFO();
controller2.setPurchase(new BigDecimal(20.0));
controller2.setSales(new BigDecimal(20.0));
controller2.clickSave();
}
controller1.clickClose();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
After the Controller class is created, a new class is created and the service method that will perform the material transfer here is written. In this meta, the company, period and language information required to create the server context object are passed as parameters. LbsControllerUtil class's executeControllerTask method also starts the material transfer process. The relevant web service class will be structured as follows.
package com.acme.customization;
import com.lbs.controllers.LbsControllerUtil;
import com.lbs.platform.interfaces.IServerContext;
import com.lbs.ws.WebServiceHelper;
public class ItemControllerWebService
{
public Object createItemCard(int firm, int period, String language)
{
try
{
IServerContext context = WebServiceHelper.getContext(firm, period, language);
ItemController task = new ItemController();
LbsControllerUtil.executeControllerTask(context, task);
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
}
Once this step is completed, the adaptation project is compiled. In the adaptation project, the .class extensions of the classes that are in and used in the adaptation project that accesses the class (ItemControllerWebService) that is written as a web service in the workspace/adaptation project/bin and the objects that are created in this class (ItemController) or static methods are taken. All these classes are placed in the corresponding folders as in the package definition (../com/acme/customization for the ItemControllerWebService class). Then the files with the .aar extension are placed inside these folders. The structure of this file with .aar extension:
-META-INF
services.xml
MANIFEST.MF
Figs. In the above steps, the other folders obtained by placing .class extension files are placed in this file as they are in the same directory as META-INF.
After this, the contents of the services.xml file are changed as follows.
<service name="ItemControllerWebService">
<description>Description ...</description>
<parameter name="ServiceClass">com.acme.customization.ItemControllerWebService
</parameter>
<parameter name="InflowSecurity">
<action>
<items>UsernameToken</items>
<passwordCallbackClass>com.lbs.ws.LbsUserPasswordCallback</passwordCallbackClass>
</action>
</parameter>
</service>
In this XML, the name of the web service is given to the name attribute of the service tag. For the name property of the parameter label, the package information of the written class is written and the other parts are left as they are. After all these operations are completed, the name of your .aar extension file should be named in the same way as the service name specified in the service tag in services.xml.
.After the aar file is renamed, it is placed under Adaptation Project / WebContentExtensionsWEB-INF / services under the adaptation project. Once this is done, the project is deployed. The following link is run on any internet browser to check if a web service has been created.
http://localhost:8080/logo/services/ItemControllerWebService?wsdl