Java Business Service (JBS) Tutorial

As promised in the last article, this is a tutorial for Siebel professionals wanting to implement a JBS.

The full source code is available from my LinkedIn Group:Impossible Siebel, for those who want to start running quickly without the usual fiddling around with a new area of configuration.

The Siebel documentation provides some good high level information on the basics of a JBS, but there is no step by step details on how to implement it.

There are a lot of missing pieces that you just have to figure out yourself, and to make things harder, there is little chance we can get it running without Java knowledge.

This is illustrated by one customer who raised the following SR (ID: 490022.1), and asked all the right questions, but the explanation still didnt connect the dots, the author was obviously on a high plane, co-incidently the author who replied to this SR, is one of my favourite engineers on Support Web, Mr Pascal Kitaeff.

Complement of information about Java Business Service [ID 490022.1]

[JBS for Dummies]

Assuming that Siebel professionals dont speak Java, i'll attempt to translate.

Firstly why use a JBS? Using a JBS allows us to implement features that are not available out of the box. We can leverage all of the open source software that already been built and tested, and just plug and play in Siebel.

[Solution Overview]

1) Setup up the Java Subsystem
2) Implement a specialised eScript BS
3) Build a Java Class
4) Implement the program logic in Java

[Pre-requisites]

1. Download and install the Java SDK from http://developers.sun.com/downloads

Dont install this for fun, otherwise it will eat up valuable profile space on space restricted enterprise connected machines.

2. Download and install a JAVA IDE

Eclipse seems to be the most popular www.eclipse.org

or Netbeans, if you want to go for the Sun product
www.netbeans.org


[Setup up the Java Subsystem]

This is the easiest part. Go to your Client CFG file and create the following section
[JAVA]
DLL = <Program path>\jvm.dll
CLASSPATH = <Siebel Tools path>\CLASSES\Siebel.jar;<Siebel Tools path>\CLASSES\ImposSiebelXSLT.jar
VMOPTIONS = -Xrs -Djava.compiler=NONE


This can also be implemented as a Server profile configuration, see bookshelf for more information, but most developers will want to try this out on the local machine.

[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.

[Java Class]

If you havn't already done so, you need to have your SDK and IDE installed at this point.

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

public class ImposSiebelXSLT extends com.siebel.eai.SiebelBusinessService {
    public void doInvokeMethod(String methodName, SiebelPropertySet input, 
                SiebelPropertySet output) throws SiebelBusinessServiceException {


6. Add the following code to perform the XSLT transformation

            StreamSource xmlSource      = new StreamSource(new StringReader(input.getValue()));
            StreamSource xsltSource     = new StreamSource(new StringReader(input.getProperty("XSLTBuffer")));
            Writer outWriter            = new StringWriter();
            StreamResult result         = new StreamResult( outWriter );
            TransformerFactory transFact = TransformerFactory.newInstance();
            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 classpath 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.

BS: ImposSiebelXSLT Business Service

[Input Property]
<Value>: XML String
XSLTBuffer: XSLT String

[Output Property]
<Value>: Transformed XML String

[Final thoughts]

Taking the the leap into JBS and using a 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.

Customers who are affected by the 30 namespace problem have a few options as highlighted in the last article.

JBS's arent the solution to everything, but it provides a door to the open source community.

The Java package for this article can be downloaded from LinkedIn: Impossible Siebel

In the final article in this series, i'll look at implementing XSLT 2.0 in Siebel.


17 comments:

  1. Excellent artical!!!

    ReplyDelete
  2. this works in siebel 7.5?

    ReplyDelete
  3. Hi Anon, JBS's were introduced in 7.7

    ReplyDelete
  4. in siebel 7.5 how can i call my java class ??
    i need send html email but in siebel i couldnt do it so i make it in java but i need send since siebel the information to java and send email

    ReplyDelete
  5. Hi Gaby, have you looked at outbound com mgr? sending HTML emails have been possible from 6 and possibly earlier.

    ReplyDelete
  6. I'm confused by your example. Is XSLT somehow linked to the concept of a JBS, or was that just what you chose as an example? Could you have done a "Hello World" JBS with no mention of XSLT?

    ReplyDelete
  7. Hi Joe,

    The subject of XSLT is tied to the related first article mentioned at the beginning.

    The body of "doInvokeMethod" is where you would perform your hello world

    regards

    ReplyDelete
  8. Hi..

    I tried to invoke the jbs. But it throws the following error: "Error invoking service 'JavaTest', method 'Invoke' at step 'jbs'.(SBL-BPR-00162)
    --
    Class name incorrect or does not extend SiebelBusinessService : HelloWorld -- JVM Exception:java.lang.NoClassDefFoundError: HelloWorld(SBL-EAI-05010)" But I have saved jar file in classes folder with same class name. Pls guide me in this.

    ReplyDelete
  9. Can we pass the field values from the Siebel to java class with this ????

    ReplyDelete
  10. Hi Karthik,

    Yes. The Input PropertySet (your field values) is passed from your Business Service into the JBS.

    ReplyDelete
  11. >java.lang.NoClassDefFoundError

    This is likely due to the jar not being added to your Subsystem configuration

    ReplyDelete
  12. hi Jason
    i have a requirement to open a file in the siebel UI, which is actually residing on another server.
    have tried window.open in JS it does work but the problem is we have hosted our siebel application on internet and dont want to do window.open which will expose the URL on the internet and cause a security problem.

    Please let me know your thoughts on this.

    ReplyDelete
  13. Hi Jason,

    Is it possible to use the interface objects as SiebelDataBean without performing a new are connected with ObjMngr, and using the current call-stack JBS?

    ReplyDelete
  14. Hi Jason, how do I know that the Jar is working properly? Where can I checks which are the active jars that we are using in an environment? Thank you in advance

    ReplyDelete
  15. Hi,
    Does JBS always points to JAVA subsystem ? If I have another JVM subsystem how can I make my java business service point to new JVM subsystem? Please help

    ReplyDelete
  16. Hi, if your java method responds then you know that it is working, alternatively If you cache the loading of your Jar, or after the first invocation of the JBS, it should leave a file lock on the JAR. If you attempt to delete it, it should alert you that it is in use by the system. (back it up first =).

    ReplyDelete
  17. @Enigma, Sorry, I havn't come across the need to use a different subsystem. Whats the requirement in your scenario?

    ReplyDelete

Comments are open to all, please make it constructive.