Example of a Java Business Service
Following is an example of a Java class implementing a business service:
package com.example.jbs;
import com.siebel.data.SiebelPropertySet;
import com.siebel.eai.SiebelBusinessServiceException;
public class AddBusinessService extends com.siebel.eai.SiebelBusinessService {
public void doInvokeMethod(String methodName, SiebelPropertySet input,
SiebelPropertySet output) throws SiebelBusinessServiceException {
String X = input.getProperty("X");
String Y = input.getProperty("Y");
if (X == null || X.equals("") || (Y == null) || Y.equals(""))
throw new SiebelBusinessServiceException("NO_PAR", "Missing param");
if (!methodName.equals ("Add"))
throw new SiebelBusinessServiceException("NO_SUCH_METHOD�?, "No such method");
else {
int x = 0;
int y = 0;
try {
x = Integer.parseInt(X);
y = Integer.parseInt(Y);
}
catch (NumberFormatException e) {
throw new SiebelBusinessServiceException("NOT_INT", "Noninteger passed");
}
int z = x + y;
output.setProperty("Z", new Integer(z).toString());
}
}
}