Usage of Java In Siebel Part 2
Usage of Java In Siebel Part 2
Part 2
1|Page
Table of Contents
1- Steps to implement a JBS .......................................................................................................... 3
2- Example of a Java Business Service: ......................................................................................... 6
3- Final thoughts: .......................................................................................................................... 7
2|Page
1- Steps to implement a JBS
Solution overview:
1) Setup the java subsystem
2) Implement a specialized eScript BS
3) Build a Java Class
4) Implement the program logic in Java
[JAVA]
eScript BS:
1. Create a BS based on the class: "CSSJavaBusinessService"
2. Call it "ImposSiebelXSLT Business Service"
3. Create a BS user property with the following values
Name: @class
Value:ImposSiebelXSLT
This BS will be barebones and just pass the method down into the Java class,
where the real work will happen
3|Page
Java Class:
1.Create a new project of type "Java Class Library" called "ImposSiebelXSLT"
2.Link the Siebel.jar file to your project libraries
3.Create a new class called "ImposSiebelXSLT"
4.Add the following code to import the required Clases
import com.siebel.data.SiebelPropertySet;
import com.siebel.eai.SiebelBusinessServiceException;
import java.io.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.*;
5. Add the following code to inherit from the Siebel Business Service class
4|Page
6. Add the following code to perform the XSLT transformation
javax.xml.transform.Transformer trans;
trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, result);
output.setValue(result.getWriter().toString());
output.setProperty("ErrorMessage", ErrMsg);
7. Compile and place the Jar file into your class path as defined in your
configuration file above.
Usage:
Now we can call the JBS like any other eScript business service, by passing in
input and output property sets.
5|Page
BS:ImposSiebelXSLTBusinessService
[InputProperty]
<Value>:XMLString
XSLTBuffer:XSLTString
[OutputProperty]
<Value>:Transformed XML String
package com.example.jbs;
import com.siebel.data.SiebelPropertySet;
import com.siebel.eai.SiebelBusinessServiceException;
public class AddBusinessService extends com.siebel.eai.SiebelBusinessService {
if (!methodName.equals ("Add"))
int x = 0;
6|Page
int y = 0;
try {
x = Integer.parseInt(X);
y = Integer.parseInt(Y);
}
catch (NumberFormatException e) {
int z = x + y;
output.setProperty("Z", new Integer(z).toString());
}
}}
3- Final thoughts:
Taking the leap into JBS and using an entirely new XSLT parser can be a risky
undertaking, it means that your entire application needs to be regression tested.
This is the same problem Siebel would have to face, if it replace its XSLT
engine.
So what should we do?
If you dont have any problems with your "EAI XSLT Service", it is best to leave
it alone.
JBS's arent the solution to everything, but it provides a door to the open source
community.
7|Page