Oracle Communication Service Gatekeeper (OCSG)
Communication Service Plugins
Development Procedures
Introduction
This document provides the development procedures for Telkom Speedy Service Soap2Soap Communication Service on OCSG, including code generation, code modification, building, deployment, provision and unit testing.
Prerequisite
-
Download OCSG 4.1.1 installation package
-
Download OCSG 4.1 documenation package
-
[OPTIONAL] Read “Concepts and Architectural Overview”
- [OPTIONAL] Read “Platform Development Studio – Developer’s Guide”
-
Installation of Eclipse 3.5 or later
Creating Communication Service OCSG using Eclipse IDE
Before creating CS (Communication Service) in Eclipse, make sure that the OCSG plugin is already installed in your Eclipse plugin directory. In this case, we assume that we have OCSG plugins in our Eclipse plugin directory.
To start creating CS, first run your Eclipse IDE

and go to the workbench for start creating project (shown in picture below).

Click File on the menu and choose new project or we can use keyboard shortcut CTRL + N. For the project, choose Communication Project (Shown in picture below).
Press NEXT button for start creating CS project (Shown in picture below). In the Project Name, name your project based on service purpose or name it as u like. DON’T check the use predefined communication service because our goal is to CREATE NEW communication service plugin and NOT USE created communication service plugin. Press Next for go to Next Step.
Now we configuring NT plugin CS (for communicating with internal network). First add WSDL file to our cs project it is use for generating template code of NT CS, what the method exist and how to use that method. Press “+” icon in the configure Service WSDL File for adding WSDL file
wsdl file is an XML type file with an extension of WSDL (eg. Service.wsdl), If you can’t figure it out, see the picture below. Press OK button if you have find the wsdl file.
After we press OK button, we go back to the previous windows that is configuring NT service. Fill all the necesary field as shown in the picture below. The value of all data is depend on your call, but the description of the field is like this :
a. Company : The company name belong to the service.
b. Version : Service version number (e.g : 1.0 | 2.1 | 4.1.1) it will shown in the admin console of OCSG
c. Service type : Service type of our communication service, (e.g : Post | Get | cekNotel information)
d. Java Class Package Name : The java package name (basic in package naming of java source project. e.g : com.telkom.siska.speedy.service | com.example.service).
e. Context Path : The URI path of the service (e.g : path/service | service | parlayx44/service).
Note : Don’t check the Support Type checkbox.
See the picture below to see what to do and don’t. Press NEXT button to go to next step.
After we finish configuring the NT service, now we start to configure the AT layer service. AT layer service is web service where the third application will invoke to. To create AT layer service, just click the icon and it will show popup windows to begin configuring the AT Layer (shown it the picture below).
Like the NT layer data, we must fill all the necesary informatio regarding to AT layer service. All the information describes below ;
a. Protocol : Protocol name use in AT service (e.g : soap | rest | bla | etc )
b. Schemes : don’t fill the information.
c. Package Name : Same as the NT layer, this is the java basic package naming.
d. Company : Company name that owned the service.
e. Version : Service version (e.g : 1.0 | 2.1 | 4.1.1 )
f. Type : The Service type, (default is SOAP type services).
See the complete in the picture bellow
After all the necessary information filled, now press Finish button.
Wait after the generate process finish, Eclipse now is build our code based on the template information that we set in this configuration.
After the process finish, it will generate the java code, like shown below.
Now we must add some java code in the generated java file of CS project.
Example code for AT interface Telkom Siska is shown below :
package com.get.response.hello.helloport.north;
import org.apache.log4j.Logger;
import com.bea.wlcp.wlng.api.edr.Edr;
import com.get.response.hello.plugin.HelloPlugin;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
/**
*
* This class was generated on <I>Tue May 24 00:20:13 WIT 2011</I>.
*
*/
publicclass HelloPluginImpl implements HelloPlugin {
privatestaticfinal Logger logger = Logger.getLogger(HelloPluginImpl.class);
/**
* <B>helloName</B>
*
*/
@Edr
public java.lang.String helloName(java.lang.String HelloName)
{
logger.trace(“METHOD_IN”);
String result = null;
try{
String EndPointURL = “http://localhost:8021/HelloWorld/helloService?WSDL”;
String methodName = “HelloName”;
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(EndPointURL));
call.setOperation(methodName);
call.addParameter(“name”, XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
result = (String)call.invoke(new Object[]{“DIMAS”});
}
catch(Exception e){
logger.error(e.getMessage());
}
return result;
//throw new RuntimeException(“Not yet implemented”);
}
}
That is the Axis based code for invoke web services. Read Axis Web Service document for complete documentation.
Below is the example code for Communication Service Java Bean. The java code will generate automatically by Eclipse, but for custom purpose we must add java code in it. Naming of the file will be likes this (your protocol name)Bean.java.
package com.speedy.siska.services.get.management;
importcom.bea.wlcp.wlng.api.management.ManagementException;
/**
* This is the generated code for management interface for the Plug-in
*
* @author Copyright (c) 2005 by BEA Systems, Inc. All Rights Reserved.
*/
//Edit this file to add/modify required management attributes and operations
publicinterface GetMBean {
/**
* Description of sampleAttribute
*/
public String sampleAttribute = “defaultValue”;
/**
* Description of sampleOperation
* @param param1 Description for param1
* @param param2 Description for param2
* @return
* @throws ManagementException
*/
}
The BeanImplementation (BeanImpl.java) is extended java class for Java Bean or in this case is extended for GetBean.java. In the Bean, we define methods for creating custom configuration to the CS plugin in the OCSG. In the BeanImpl.java we construct the workflow of the methods that we define first in the Bean java. So, the methods in the Bean must exist and use name also parameters same as define in the Bean java file.
Bellow is the example code for ProsesStudi BeanImpl.java
package com.speedy.siska.services.get.management;
import com.bea.wlcp.wlng.api.management.WLNGMBeanDelegate;
import com.bea.wlcp.wlng.api.management.ManagementException;
import org.apache.log4j.Logger;
import javax.management.NotCompliantMBeanException;
/**
* This is the management implementation for the plugin
*
* @author Copyright (c) 2005 by BEA Systems, Inc. All Rights Reserved.
*
* This class was generated on <I>Wed May 25 23:32:57 WIT 2011</I>.
*/
// Edit this file to add/modify required management attributes and operations
public class GetMBeanImpl extends WLNGMBeanDelegate implements GetMBean {
private String sampleAttribute = ” “;
private static final Logger logger = Logger.getLogger(GetMBeanImpl.class);
/**
* Default constructor
*
* @throws NotCompliantMBeanException thrown on failure to to register an
* object in the MBean server.
*/
public GetMBeanImpl() throws NotCompliantMBeanException {
super(GetMBean.class);
logger.trace(“METHOD_IN”);
}
}
Note :
As we can see, in the GetMBean.java we didn’t create any methods and so in the GetMBeanImpl.java we didn’t create any workflow for the methods that we define in the GetMBean.java.
We move to next java code that is PluginService.java. In the PluginService.java we construct the methods for the plugin service. Before we can use the CS plugin in the OCSG, the plugin must exist in the OCSG as the plugin service first. So in this code we construct for that activity.
The code itself is auto generated by Eclipse, we don’t need to add anything in it but if we want to add the activity to the log file for debuging activity just add this logger.trace(“METHOD_IN”); into all the methods. It will create log file for all activity in the plugin service.
Below is the complete code for Prosestudi Plugin Service java code.
package com.speedy.siska.services.get;
import javax.management.ObjectName;
import com.bea.wlcp.wlng.api.plugin.ServiceType;
import com.bea.wlcp.wlng.api.plugin.ManagedPluginService;
import com.bea.wlcp.wlng.api.plugin.common.DeploymentException;
import com.bea.wlcp.wlng.api.plugin.CompletionBarrier;
import com.bea.wlcp.wlng.api.plugin.ManagedPluginInstance;
import com.bea.wlcp.wlng.api.plugin.PluginPool;
import com.speedy.siska.services.get.management.GetMBean;
import org.apache.log4j.Logger;
/**
* Plugin service implementation.
*/
public class GetPluginService implements ManagedPluginService {
/** Supported address schemes */
private static final String[] SUPPORTED_SCHEMES = { “” };
private static final Logger logger = Logger.getLogger(GetPluginService.class);
/**
* Plugin service id
*/
private String id;
/**
* Plugin pool
*/
@SuppressWarnings(“unused”)
private PluginPool pool;
/**
* Instantiates the plugin.
*/
public GetPluginService() {
logger.trace(“METHOD_IN”);
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginServiceLifecycle#init(String, com.bea.wlcp.wlng.api.plugin.PluginPool)
*/
public void init(String id, PluginPool pool) {
logger.trace(“METHOD_IN”);
this.id = id;
this.pool = pool;
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginServiceLifecycle#doStarted()
*/
public void doStarted() throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginServiceLifecycle#doStopped()
*/
public void doStopped() throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginServiceLifecycle#doActivated()
*/
public void doActivated() throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginServiceLifecycle#doDeactivated()
*/
public void doDeactivated() throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginServiceLifecycle#handleResuming()
*/
public void handleResuming() throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginServiceLifecycle#handleSuspending(CompletionBarrier)
*/
public void handleSuspending(CompletionBarrier barrier) throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginServiceLifecycle#handleForceSuspending()
*/
public void handleForceSuspending () {
logger.trace(“METHOD_IN”);
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginService#getSupportedSchemes()
*/
public String[] getSupportedSchemes() {
logger.trace(“METHOD_IN”);
return SUPPORTED_SCHEMES;
}
public ServiceType getServiceType() {
logger.trace(“METHOD_IN”);
return com.speedy.siska.services.servicetype.GetServiceType.type;
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginService#getNetworkProtocol()
*/
public String getNetworkProtocol() {
logger.trace(“METHOD_IN”);
return “get”;
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginInstanceFactory#createInstance(String)
*/
public ManagedPluginInstance createInstance(String pluginInstanceId) throws DeploymentException {
logger.trace(“METHOD_IN”);
return new GetPluginInstance(pluginInstanceId);
}
}
As we mentioned before, before we can use the plugin, it must exist in the OCSG as plugin service first. And after the plugin exist as the plugin service in the OCSG we must create it instance. In this java code, the workflow of the instance plugin service will describes in this java code.
package com.speedy.siska.services.get;
import com.bea.wlcp.wlng.api.management.MBeanManager;
import com.bea.wlcp.wlng.api.plugin.ManagedPluginInstance;
import com.bea.wlcp.wlng.api.plugin.common.DeploymentException;
import com.bea.wlcp.wlng.api.plugin.PluginInterfaceHolder;
import com.bea.wlcp.wlng.api.plugin.RequestInfo;
import org.apache.log4j.Logger;
import java.util.List;
import java.util.ArrayList;
import javax.management.ObjectName;
import com.speedy.siska.services.plugin.Getnotel_InfoPlugin;
import com.speedy.siska.services.get.getnotel_infoport.north.Getnotel_InfoPluginImpl;
import com.speedy.siska.services.get.management.GetMBean;
import com.speedy.siska.services.get.management.GetMBeanImpl;
/**
* Plugin Instance implementation.
*/
public class GetPluginInstance implements ManagedPluginInstance {
/**
* North interfaces
*/
private final List<PluginInterfaceHolder> northList = new ArrayList<PluginInterfaceHolder>();
private static final Logger logger = Logger.getLogger(GetPluginInstance.class);
/**
* South interfaces
*/
private final List<PluginInterfaceHolder> southList = new ArrayList<PluginInterfaceHolder>();
/**
* The plug-in instance id.
*/
private final String id;
private GetMBean MBean;
private ObjectName MBeanName;
/**
* Constructor.
*/
public GetPluginInstance(String id) {
logger.trace(“METHOD_IN”);
this.id = id;
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginInstanceLifecycle#activate()
*/
public void activate() throws DeploymentException {
logger.trace(“METHOD_IN”);
try {
MBean = new GetMBeanImpl();
MBeanName = MBeanManager.constructObjectName(GetPluginInstance.class.getName(), this.id);
MBeanManager.registerMBean(MBean, MBeanName, this.id);
Getnotel_InfoPluginImpl pluginImpl = new Getnotel_InfoPluginImpl();
northList.add(new PluginInterfaceHolder(Getnotel_InfoPlugin.class, pluginImpl));
} catch (Throwable e) {
if(MBean != null){
try{
MBeanManager.unregisterMBean(MBeanName);
}
catch(Throwable a){
a.printStackTrace();
}
}
throw new DeploymentException(e);
}
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginInstanceLifecycle#deactivate()
*/
public void deactivate() throws DeploymentException {
logger.trace(“METHOD_IN”);
}
/*
* @see com.bea.wlcp.wlng.plugin.PluginInstance#isConnected()
*/
public boolean isConnected() {
logger.trace(“METHOD_IN”);
return true;
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginInstance#getNorthInterfaces()
*/
public List<PluginInterfaceHolder> getNorthInterfaces() {
logger.trace(“METHOD_IN”);
return northList;
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginInstance#getSouthInterfaces()
*/
public List<PluginInterfaceHolder> getSouthInterfaces() {
logger.trace(“METHOD_IN”);
return southList;
}
/**
* @see com.bea.wlcp.wlng.api.plugin.PluginInstance#customMatch(com.bea.wlcp.wlng.api.plugin.RequestInfo)
*/
public int customMatch(RequestInfo requestInfo) {
logger.trace(“METHOD_IN”);
return MATCH_OPTIONAL;
}
}
The last is the AT part of the plugin that face to the external network. In this java code, we describes the flow what the plugin do when third application invoked / call it.
Because the purpose of the plugin is to return the Notel speedy status to the third application based on the Notel parameter. So we just create the code for invoke / call the web service exist in the NT network.
This java file is also autogenerate by Eclipse, all we need to do is replace this code Thrown not complianceException by our code.
Below is the complete code in the PluginImplementation.
package com.speedy.siska.services.get.getnotel_infoport.north;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
//import java.net.MalformedURLException;
import java.net.Socket;
//import java.rmi.RemoteException;
//import javax.xml.namespace.QName;
//import javax.xml.rpc.ParameterMode;
//import javax.xml.rpc.ServiceException;
import com.bea.wlcp.wlng.api.edr.Edr;
//import org.apache.axis.client.Call;_return
//import org.apache.axis.client.Service;
//import org.apache.axis.encoding.XMLType;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import com.speedy.siska.services.plugin.Getnotel_InfoPlugin;
import com.telkom.sdp.speedy.services.NotelinformResponse;
import com.telkom.sdp.speedy.services.Test;
/**
*
* This class was generated on <I>Wed May 25 23:32:55 WIT 2011</I>.
*
*/
public class Getnotel_InfoPluginImpl implements Getnotel_InfoPlugin {
/**
* <B>notelinform</B>
*
*/
private static final Logger logger = Logger.getLogger(Getnotel_InfoPluginImpl.class);
@Edr
public com.telkom.sdp.speedy.services.NotelinformResponse notelinform(com.telkom.sdp.speedy.services.Test parameters)
{
/*
NotelinformResponse response = new NotelinformResponse();
NotelInformation information = new NotelInformation();
String resp = NotelInformation.GetInfo(parameters.getInput().toString());
response.setReturn(resp);
return response;
*/
StringBuilder sb = new StringBuilder();
try {
String XMLRequest = “<soapenv:Envelope”+” xmlns:soapenv=\”http://schemas.xmlsoap.org/soap/envelope/\”"+” xmlns:ser=\”http://services.speedy.sdp.telkom.com/\”>”+
“<soapenv:Header/>”+
“<soapenv:Body>”+
“<ser:test>”+
“<input>”+parameters.getInput()+”</input>”+
“</ser:test>”+
“</soapenv:Body>”+
“</soapenv:Envelope>”;
//Create socket
String hostname = “10.0.40.101″;
int port = 8001;
InetAddress addr = InetAddress.getByName(hostname);
Socket sock = new Socket(addr, port);
//Send header
String path = “/Telkom_Speedy_WS/getnotel_infoService”;
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),”UTF-8″));
// You can use “UTF8″ for compatibility with the Microsoft virtual machine.
wr.write(“POST ” + path + ” HTTP/1.0\r\n”);
wr.write(“Host: 10.0.40.101\r\n”);
wr.write(“Content-Length: ” + XMLRequest.length() + “\r\n”);
wr.write(“Content-Type: text/xml; charset=\”utf-8\”\r\n”);
wr.write(“\r\n”);
//Send data
wr.write(XMLRequest);
wr.flush();
System.out.println(XMLRequest);
System.out.println(“_________________________________________________________________”);
// Response
BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line;
while((line = rd.readLine()) != null)
{
sb.append(line);
}
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println((StringUtils.substringBetween(sb.toString(), “<return>”, “</return>”)));
//res.setResult((StringUtils.substringBetween(sb.toString(), “<return>”, “</return>”)));
NotelinformResponse response = new NotelinformResponse();
response.setReturn((StringUtils.substringBetween(sb.toString(), “<return>”, “</return>”)));
//System.out.println(“DIMAS”);
//System.out.println(“DIMAS”);
return response;
}
}
After we write all the code. Is time to compile java code using ANT generated function. Before we can compile it, we must add several parameter into Build.xml and Common.xml file. This part we do if we use code using external library of the eclipse (e.g : Axis1 , Axis 2).
Build.xml and Common.xml are in the root of your CS project directory
Open the Build.xml file and add this <attributename=“Class-Path”value=“lib/axis-ant.jar lib/axis.jar lib/commons-logging.jar lib/jaxrpc.jar lib/saaj.jar lib/wsdl4j.jar”/>
into <targetname=“make-facade”> tag. See the picture below.
And also insert the code in the <targetname=“make-enabler”> tag. See the picture below.
After we finish edit Build.xml file, we now must edit Common.xml file. Common.xml use Build.xml as the general configuration.
Add this code
<propertyname=“lib.axis”location=“${pds.lib}/axis”/>
<propertyname=“lib.commons”location=“${pds.lib}/commons”/>
in the <!– thirdparty –> section. See picture below
Add this code
<filesetdir=“${lib.axis}”includes=“axis-ant.jar, axis.jar, jaxrpc.jar, saaj.jar, wsdl4j.jar”/>
<filesetdir=“${lib.commons}”includes=“commons-logging.jar”/>
in
<!– Defines the communication service layer generation task –> section. See the picture below.
After we finish edit Build.xml and Common.xml file, now we create library folder for store our jar library files that we use in this CS project. In the Project Explorer Eclipse, Go to services type folder. Because we name the services type GoNotel, so we go to that named folder and open the resources folder inside common folder. See the picture below.
Click File → New → Folder or CTRL + N and choose folder. It will show the popup windows, see the picture below.
Name the folder name lib under the resources and click finish button.
After we finish creating lib folder, now we add jar files into the lib folder. The jar files that we copy into lib folder is the jar files we use in the project only. Because we use axis library in our project, so we must add axis library into the lib folder. The Axis library can we found in OCSG instalation folder. In the OCSG instalation folder, go to folder WLNG_PDS400 → lib → Axis and copy all the files in the folder. See the picture below.
Go to Project Explorer in Eclipse, choose our created folder lib and paste into it. It will copy all the files into the lib folder. See the picture after we paste the file into our project folder.
After we finish copy all the necessary files into our lib folder. Now the we configure the policy for our plugin. OCSG require all the plugins has policy in it. If don’t add webservices policy, the OCSG will not authenticate it and denied access to the value of the plugin return to third application or the technical name is Filter.
To do it, we can create xml file and name it weblogic-webservices-policy.xml.
Add into the xml file this code :
<?xmlversion=’1.0′encoding=‘UTF-8′?>
<webservice-policy-refxmlns=“http://www.bea.com/ns/weblogic/90″xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
<port-policy>
<port-name>Your Port name in the wsdl file</port-name>
<ws-policy>
<uri>policy:Auth.xml</uri>
<direction>inbound</direction>
</ws-policy>
</port-policy>
</webservice-policy-ref>
save it under common directory of our project, see the picture below.
After all the steps are done, now we can compile the code using ANT generated function. Go to Build.xml under your root project directory, or in the Project Explorer of eclipse, click in the Build.xml file near Common.xml and left click your mouse or your left button touchpad and choose run as. If you want to use keyboard shortcut just press SHIFT + ALT + X + Q. See the picture below.
If we follow all the step describe before, in the generate ANT it will show BUILD SUCCESFUL. See the picture below.
But if not, probably we miss step. Just go to the error ant and see what the error is. After Build succesfull, ANT will create 2 EAR files under dist folder. See the picture below.
This 2 files are the files that we deploy into OCSG. Copy this 2 files, and paste it into folder that can be reach when we explore EAR files to be deployed into OCSG.
0.000000
0.000000