Source Code:

Custom Web Service in Java.zip

In the adaptation project, a class is created as the first process to write a web service and the operations that are desired to be performed are coded in this class. In the following example class, the MMQOItemBrowser query of the material browser is executed and the resultant client is returned.

package com.acme.customization;
 
public class CustomWebService
{
 
public String[] getFirstNItems(int firm, int period, String language, int rowCount)
{
try
{
       IServerContext context = WebServiceHelper.getContext(firm, period, language);
       IServerQueryFactory factory = context.getServerQueryFactory();
       QueryParams params = new QueryParams();
       QueryBusinessObjects items = new QueryBusinessObjects();
       factory.first("MMQOItemBrowser", params, items, rowCount, true);
       String[] results = new String[rowCount];
       if(items != null && items.size() > 0)
       {
              for(int i = 0; i < items.size(); i++)
             {
                    QueryBusinessObject item = (QueryBusinessObject) items.get(i)
                    String code = QueryUtil.getStringProp(item, "Code");
                    String name = QueryUtil.getStringProp(item, "Name");
                    String searchText = QueryUtil.getStringProp(item, "SearchText");
                    results[i] = "Code: " + code + " Name: " + name + " Search Text: " + searchText;
             }
       }
       return results;
}
catch (Exception e)
{
       e.printStackTrace();
}
return null;
}
}

Once this step is completed, the adaptation project is compiled. In the adaptation project, the .class extensions of the classes that have been created and used in the adaptation project of the class (CustomWebService) written in web service in the workspace/adaptation project/bin and objects created in this class or accessed to static methods (ProjectUtil) are taken. All of these classes are placed in the relevant folders as in the package definition (../com/acme/customization for the CustomWebService 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 is changed as follows.

<service name="CustomWebService">
      <description>Description ...</description>
      <parameter name="ServiceClass">com.acme.customization.CustomWebService</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 AlignmentProject / 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/CustomWebService?wsdl

Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım