|
.
Make
sure your SilverStream server is running and the xCommerce Server has been
loaded. On the SilverStream server
console, during startup, you will see the message
"xCommerce Server Started, Version: x.x Build:xxx"
if the xCommerce server is running. During
the server startup, it may also be worth noting the port that the JBroker ORB is
listening on (the default being 54890), since we will need this information
later.
.
Launch xCommerce
Designer.
.
Choose File...Open
Project and navigate to the \xCommerce\Samples\TutorialEnd project that was
installed during initial installation.
.
Choose File...Deploy
to start the deployment wizard.
o
Service
Description
*
In this example,
we are deploying to a SilverStream application server.
*
You can specify
any directory as your temporary staging directory; just make sure it is outside
the root of the project directory.
*
Choose a jar name
that is appropriate for your application and make note of the name (for the
example: tutorial.jar).
*
Choose a
deployment context that is appropriate for your application (for the example:
com.xcommerce.tutorial).
o
Servlet-Based
Triggers
*
This is an
optional step. Complete if your service is going to use servlet-based triggers.
o
EJB-Based Triggers
*
This is the
critical step to enable your Java application to call your xCommerce service.
*
In the first
pulldown menu, choose the service that you would like to call
*
Provide a unique
JNDI name that will be used to identify the service.
The name must be unique on the server, or you will get an
org.omg.CosNaming.NamingContextPackage.AlreadyBound exception.
The JNDI name is also case sensitive.
*
Choose a
transaction attribute that is appropriate for your service. For the example, we
choose "Not Supported".

o
The next three
dialogs are optional and are not used in this example
o
The final dialog
describes where to deploy the service.
*
Specify the server
and port of your SilverStream application server.
We will use the same information in our Java application, so it will
definitely be worth noting.
*
The server
database name that will hold your deployed objects
*
If your server is
secure, specify an administrator name and password to deploy your service.
*
In the example, we
will choose "Yes" to automatically upload the project.
o
Hit "Finish"
to deploy your service

Create
a Java program to call the service.
For
this example, we've created a small program in a file called CallXCEJB.java.
The file contains the following code:
// Core imports for calling xCommerce:
import com.sssw.b2b.xs.ejb.*; // xcs-all.jar
import com.sssw.b2b.xs.sssw.GXSEJBAccessor; // xcs-all.jar
import com.sssw.b2b.xs.ejb.IGXSEJBServiceHome; // xcs-all.jar
import com.sssw.rt.util.*; // SilverRuntime.zip
import javax.ejb.*; // ejb.jar
public class CallXCEJB {
// Change the following constants to reflect your environment. The
// JNDI name was defined when you deployed your service.
static final String sHOST = "fhamilton";
static final int iPORT = 80;
static final String sJNDINAME = "ProductLookupJNDI";
static final int iRMIPORT = 54890;
public static void main(String[] args) {
// This will hold the return value from the xCommerce service
String sReturn = "";
// Build an XML Document for the Service. Notice the escape sequence.
StringBuffer xmlDoc = new StringBuffer();
xmlDoc.append("<?xml version =\"1.0\" encoding=\"UTF-8\"?>");
xmlDoc.append("<ROOT>");
xmlDoc.append("<SKU>LOR8437</SKU>");
xmlDoc.append("</ROOT>");
try {
// Note: The following method is overloaded and can accept two additional
// Arguments: username, password. The version we are using
// has the following signature:
//
// public static java.lang.Object getHomeBean(java.lang.String className,
// java.lang.String jndiName,
// java.lang.String ejbHostname,
// int port,
// int rmiPort)
// throws java.lang.Exception
//
// But there is also:
//
// public static java.lang.Object getHomeBean(java.lang.String className,
// java.lang.String jndiName,
// java.lang.String ejbHostname,
// int port,
// int rmiPort,
// java.lang.String uname,
// java.lang.String password
// throws java.lang.Exception
IGXSEJBServiceHome srvcHome = (IGXSEJBServiceHome)
GXSEJBAccessor.getHomeBean("com.sssw.b2b.xs.ejb.IGXSEJBServiceHome",
sJNDINAME,
sHOST,
iPORT,
iRMIPORT);
IGXSEJBServiceComponent ejbSrvc = srvcHome.create();
sReturn = ejbSrvc.execute(xmlDoc.toString());
System.out.println(sReturn);
}
catch (Throwable tx) {
System.out.println(tx.getMessage());
tx.printStackTrace();
}
}
}
|