AddingFieldWebServiceExample
Code snippetName: Adding Field to a Web service
|
1. Make sure database has the column for the field you want to add.
2. You might want to add the field also to Openbravo's equivalent window tab. (I won't go through these procedures, just a mention that field needs to be in database as well in order to work properly.)
3. Modify the sqlclass to have the field in question, if fetching information from openbravo it needs to be processed in SELECT clause, if sending to openbravo in INSERT.
4. Modify the class to have proper variable and get/set functions for the field in question.
5. Modify ExternalSalesImpl to handle the data within method.
6. stop Tomcat, compile, start Tomcat and install web service, in this order
Example:
Goal: to add SKU field in getProductsCatalog method within Product array.
1. Database has SKU already stored in M_PRODUCT.SKU
2. Field wasn't made active in default installation, so I added it to Product Tab through System administration.
3. Modify ExternalSalesProduct_data.xsql file to fetch sku data from database, add M_PRODUCT.SKU AS SKU, for example after M_PRODUCT.UPC AS EAN,
4. Modify Product.java file to have variable and functions for sku, add the following:
private String sku;
public String getSku() {
return sku;
}
public void setSku( String sku ) {
this.sku = sku;
}
5. Modify ExternalSalesImpl.java file to add the correct data to correct variable:
add products[i].setSku(data[i].sku); after products[i].setEan(data[i].ean); in method: public Product[] getProductsCatalog
6. stop Tomcat, compile, start Tomcat and install web service, in this order
Thanks to Aarne Salminen to write this example in this post [1]
Category: Code Snippets

