blob: cbf1a9d9e0f36b21cadeabea18c7b342b05d18fc [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.9.2 at 2021-08-01
| Rendered using Apache Maven Fluido Skin 1.6
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20210801" />
<meta http-equiv="Content-Language" content="en" />
<title>Apache Axis2 &#x2013; Exposing CORBA Services as Web Services</title>
<link rel="stylesheet" href="../css/apache-maven-fluido-1.6.min.css" />
<link rel="stylesheet" href="../css/site.css" />
<link rel="stylesheet" href="../css/print.css" media="print" />
<script type="text/javascript" src="../js/apache-maven-fluido-1.6.min.js"></script>
<meta http-equiv="content-type" content="text/html; charset=us-ascii" /> </head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left"><a href="http://www.apache.org/" id="bannerLeft"><img src="http://www.apache.org/images/asf_logo_wide.png" alt="Apache Axis2"/></a></div>
<div class="pull-right"><a href=".././" id="bannerRight"><img src="../images/axis.jpg" /></a></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2021-08-01<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 1.8.0<span class="divider">|</span></li>
<li class=""><a href="http://www.apache.org" class="externalLink" title="Apache">Apache</a><span class="divider">/</span></li>
<li class=""><a href="../index.html" title="Axis2/Java">Axis2/Java</a><span class="divider">/</span></li>
<li class="active ">Exposing CORBA Services as Web Services</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Axis2/Java</li>
<li><a href="../index.html" title="Home"><span class="none"></span>Home</a> </li>
<li><a href="../download.html" title="Downloads"><span class="none"></span>Downloads</a> </li>
<li><a href="javascript:void(0)" title="Release Notes"><span class="icon-chevron-down"></span>Release Notes</a>
<ul class="nav nav-list">
<li><a href="../release-notes/1.6.1.html" title="1.6.1"><span class="none"></span>1.6.1</a> </li>
<li><a href="../release-notes/1.6.2.html" title="1.6.2"><span class="none"></span>1.6.2</a> </li>
<li><a href="../release-notes/1.6.3.html" title="1.6.3"><span class="none"></span>1.6.3</a> </li>
<li><a href="../release-notes/1.6.4.html" title="1.6.4"><span class="none"></span>1.6.4</a> </li>
<li><a href="../release-notes/1.7.0.html" title="1.7.0"><span class="none"></span>1.7.0</a> </li>
<li><a href="../release-notes/1.8.0.html" title="1.8.0"><span class="none"></span>1.8.0</a> </li>
</ul>
</li>
<li><a href="../modules/index.html" title="Modules"><span class="none"></span>Modules</a> </li>
<li><a href="../tools/index.html" title="Tools"><span class="none"></span>Tools</a> </li>
<li class="nav-header">Documentation</li>
<li><a href="../docs/toc.html" title="Table of Contents"><span class="none"></span>Table of Contents</a> </li>
<li><a href="../docs/installationguide.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li>
<li><a href="../docs/quickstartguide.html" title="QuickStart Guide"><span class="none"></span>QuickStart Guide</a> </li>
<li><a href="../docs/userguide.html" title="User Guide"><span class="none"></span>User Guide</a> </li>
<li><a href="../docs/jaxws-guide.html" title="JAXWS Guide"><span class="none"></span>JAXWS Guide</a> </li>
<li><a href="../docs/pojoguide.html" title="POJO Guide"><span class="none"></span>POJO Guide</a> </li>
<li><a href="../docs/spring.html" title="Spring Guide"><span class="none"></span>Spring Guide</a> </li>
<li><a href="../docs/webadminguide.html" title="Web Administrator's Guide"><span class="none"></span>Web Administrator's Guide</a> </li>
<li><a href="../docs/migration.html" title="Migration Guide (from Axis1)"><span class="none"></span>Migration Guide (from Axis1)</a> </li>
<li class="nav-header">Resources</li>
<li><a href="../faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li>
<li><a href="../articles.html" title="Articles"><span class="none"></span>Articles</a> </li>
<li><a href="http://wiki.apache.org/ws/FrontPage/Axis2/" class="externalLink" title="Wiki"><span class="none"></span>Wiki</a> </li>
<li><a href="../refLib.html" title="Reference Library"><span class="none"></span>Reference Library</a> </li>
<li><a href="../apidocs/index.html" title="Online Java Docs"><span class="none"></span>Online Java Docs</a> </li>
<li class="nav-header">Get Involved</li>
<li><a href="../overview.html" title="Overview"><span class="none"></span>Overview</a> </li>
<li><a href="../svn.html" title="Checkout the Source"><span class="none"></span>Checkout the Source</a> </li>
<li><a href="../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li>
<li><a href="../release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li>
<li><a href="../guidelines.html" title="Developer Guidelines"><span class="none"></span>Developer Guidelines</a> </li>
<li><a href="../siteHowTo.html" title="Build the Site"><span class="none"></span>Build the Site</a> </li>
<li class="nav-header">Project Information</li>
<li><a href="../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li>
<li><a href="../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li>
<li><a href="http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/" class="externalLink" title="Source Code"><span class="none"></span>Source Code</a> </li>
<li><a href="../thanks.html" title="Acknowledgements"><span class="none"></span>Acknowledgements</a> </li>
<li class="nav-header">Apache</li>
<li><a href="http://www.apache.org/licenses/LICENSE-2.0.html" class="externalLink" title="License"><span class="none"></span>License</a> </li>
<li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li>
<li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li>
<li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li>
</ul>
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../images/logos/maven-feather.png" /></a>
</div>
</div>
</div>
<div id="bodyColumn" class="span10" >
<html xmlns="http://www.w3.org/1999/xhtml">
<h1>Exposing CORBA Services as Web Services</h1>
<section>
<h2><a name="Overview"></a>Overview</h2>
<section>
<h3><a name="What_is_CORBA.3F"></a>What is CORBA?</h3>
CORBA stands for Common Object Request Broker Architecture. It allows clients to invoke methods of remote objects running on remote machines through a binary protocol such as IIOP.
</section><section>
<h3><a name="What_Axis2_CORBA_module_does.3F"></a>What Axis2 CORBA module does?</h3>
The Axis2 CORBA module acts as a bridge between SOAP and IIOP protocols by converting SOAP messages originated from a web services client to IIOP messages and vise versa. In other words, Axis2 CORBA module allows web service client to invoke methods on a remote CORBA server.
<section>
<h4><a name="Features"></a>Features</h4>
<ul>
<li>Supports all the primitive and composite IDL data types including Value types (objects by value), Structures, Union, Sequences and Arrays (including multidimensional arrays), Enumerations and Exceptions.</li>
<li>Dynamic conversion of complex data types</li>
<li>IDL driven WSDL generation</li>
<li>Supports CORBA pre-processor directives</li>
</ul>
</section></section><section>
<h3><a name="Why_it_is_Useful.3F"></a>Why it is Useful?</h3>
<ul>
<li>Convert legacy CORBA services into web services</li>
<li>Facilitate interoperability between heterogeneous systems</li>
<li>Integrate CORBA services with Enterprise Service Buses (ESBs)</li>
</ul>
</section><section>
<h2><a name="Tutorial"></a>Tutorial</h2>
This tutorial explains how to write a simple CORBA service and how to make it available as a web service using the Axis2 CORBA module. Let's start the tutorial by creating an IDL file.
<section>
<h3><a name="Prerequisites"></a>Prerequisites</h3>
<ul>
<li>Sun JDK version 5.0 or higher</li>
<li>Latest version of Axis2 with Axis2 CORBA module</li>
</ul>
</section><section>
<h3><a name="Creating_the_IDL_file"></a>Creating the IDL file</h3>
The Interface Definition Language (IDL) is used to describe the interface to a CORBA object. An IDL file can then be used to generate the source code for the CORBA server.
Copy the following listing and save as a text file named <code>calculator.idl</code>.
<div>
<pre>
// Address book system module
module example
{
// A data structure which contains two integer values
struct numbers
{
long first;
long second;
};
// Specify interface to our address book
interface calculator
{
// returns n.first + n.second
long add(in numbers n);
// returns n.first + n.second
long subtract(in numbers n);
};
};
</pre></div>
</section><section>
<h3><a name="Creating_the_CORBA_server"></a>Creating the CORBA server</h3>
Open a console window and type the following command. (Make sure JAVA_HOME/bin is included to the PATH environment variable)
<div>
<pre>idlj -fall calculator.idl</pre></div>
idlj generates several classes needed for CORBA servers and client. Typically, idlj command will generate the following file structure.
<div>
<pre>
|
| calculator.idl
|
\---example
numbersHelper.java
numbersHolder.java
numbers.java
calculatorPOA.java
_calculatorStub.java
calculatorHolder.java
calculatorHelper.java
calculator.java
calculatorOperations.java
</pre></div>
Goto the example subdirectory and create <code>calculatorImpl.java</code> file as follows.
<div>
<pre>
package example;
import example.calculatorPackage.numbers;
public class calculatorImpl extends calculatorPOA {
public int add(numbers n) {
return n.first + n.second;
}
public int subtract(numbers n) {
return n.first - n.second;
}
}
</pre></div>
Go back to the root directory (the directory where calculator.idl is located) and create <code>Server.java</code> as follows.
<div>
<pre>
import java.io.*;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import example.calculatorImpl;
public class Server {
public static void main(String[] args) {
org.omg.CORBA_2_3.ORB orb =
(org.omg.CORBA_2_3.ORB) org.omg.CORBA.ORB.init(args, null);
try {
org.omg.PortableServer.POA poa =
org.omg.PortableServer.POAHelper.narrow(
orb.resolve_initial_references(&quot;RootPOA&quot;));
poa.the_POAManager().activate();
org.omg.CORBA.Object o =
poa.servant_to_reference(new calculatorImpl());
if(args.length == 1) {
PrintWriter ps = new PrintWriter(new FileOutputStream(args[0]));
ps.println(orb.object_to_string(o));
ps.close();
} else {
NamingContextExt nc =
NamingContextExtHelper.narrow(
orb.resolve_initial_references(&quot;NameService&quot;));
nc.bind(nc.to_name(&quot;calculator&quot;), o);
}
} catch (Exception e) {
e.printStackTrace();
}
orb.run();
}
}
</pre></div>
Compile all the Java classes by using the following command.
<div>
<pre>javac *.java</pre></div>
</section><section>
<h3><a name="Creating_the_CORBA_web_service"></a>Creating the CORBA web service</h3>
Now we are ready to create a CORBA web service using the Axis2 CORBA module. First of all we have to prepare Axis2 to work with CORBA module.
<br /><br />
1. Make sure axis2-corba-{version}.jar is available in AXIS2_HOME/lib directory.
<br /><br />
2. Download latest Apache Yoko binary distribution form http://cwiki.apache.org/YOKO/download.html. Extract the downloaded archive to a temporary directory and copy yoko-core-{version}.jar and yoko-spec-corba{version}.jar to AXIS2_HOME/lib directory. (Axis2 CORBA module can also work with other CORBA implementations. Refer 'Additional Configuration Details' section for more information.)
<br /><br />
3. Add the following line to the &lt;axisconfig&gt; section of the axis2.xml file which is located in AXIS2_HOME/conf directory.<br />
<div>
<pre>&lt;deployer extension=&quot;.xml&quot; directory=&quot;corba&quot; class=&quot;org.apache.axis2.corba.deployer.CorbaDeployer&quot;/&gt;</pre></div>
<br />
4.Create a new directory named corba inside AXIS2_HOME/repository directory.
<br /><br />
Now, your Axis2 server is ready to deploy CORBA web services. Copy calculator.idl file to the newly created corba directory and create a new file named <code>calculator.xml</code> as follows inside the same directory.
<div>
<pre>
&lt;service name=&quot;Calculator&quot;&gt;
&lt;description&gt;Calculator Service&lt;/description&gt;
&lt;parameter name=&quot;idlFile&quot;&gt;calculator.idl&lt;/parameter&gt;
&lt;parameter name=&quot;interfaceName&quot;&gt;example::calculator&lt;/parameter&gt;
&lt;parameter name=&quot;namingServiceUrl&quot;&gt;corbaloc::localhost:900/NameService&lt;/parameter&gt;
&lt;parameter name=&quot;objectName&quot;&gt;calculator&lt;/parameter&gt;
&lt;/service&gt;
</pre></div>
Running the Example
Start a console window and execute the following command to start the CORBA name service.
<div>
<pre>tnameserv -ORBInitialPort 900</pre></div>
Start an other console window and goto the directory where Server.java is located. Execute the following command to start the CORBA server.
<div>
<pre>java Server</pre></div>
Start the Axis2 server. The EPR of the new Calculator web service will be <code>http://localhost:8080/axis2/services/Calculator</code>. The WSDL is located at <code>http://localhost:8080/axis2/services/Calculator?wsdl</code>. Now you can create a web service client and use it to invoke methods on the CORBA server.
</section><section>
<h3><a name="Additional_Configuration_details"></a>Additional Configuration details</h3>
The service definition file (eg. calculator.xml) supports the following parameters.
<br />
<table border="0" class="table table-striped">
<tr class="a">
<th>Parameter Name</th>
<th>Description</th>
<th>Required</th>
</tr>
<tr class="b">
<td>idlFil</td>
<td>Relative path to the IDL file</td>
<td>Yes</td>
</tr>
<tr class="a">
<td>orbClass</td>
<td>Overrides the default orb class name.</td>
<td>No</td>
</tr>
<tr class="b">
<td>orbSingletonClass</td>
<td>Overrides the default orb singleton class name.
(Default: org.apache.yoko.orb.CORBA.ORB)</td>
<td>No</td>
</tr>
<tr class="a">
<td>namingServiceUrl</td>
<td>URL of the CORBA naming service
(Default: org.apache.yoko.orb.CORBA.ORBSingleton)</td>
<td>No</td>
</tr>
<tr class="b">
<td>iorFilePath</td>
<td>Path to IOR file</td>
<td>No</td>
</tr>
<tr class="a">
<td>iorString</td>
<td>IOR as a string</td>
<td>No</td>
</tr>
<tr class="b">
<td>objectName</td>
<td>Name of the CORBA service which used in the naming service
Required if namingServiceUrl is present
interfaceName
Full name of the IDL interface used for the web service. (use :: as the separator between module and interface names)</td>
<td>Yes</td>
</tr>
</table>
<br />
</section><section>
<h3><a name="Notes:"></a>Notes:</h3>
1. Axis2 CORBA module uses Apache Yoko as the default CORBA implementation. If you want to use a CORBA implementation other than Apache Yoko, override orbClass and orbSingletonClass properties.
<br /><br />
2. To run the above tutorial without a naming service:<br />
Use <code>java Server /path/to/a/new/file</code> to start the server. Remove <code>namingServiceUrl</code> and <code>objectName</code> properties from the <code>calculator.xml</code> file and add the following line to the same file.
<div>
<pre>&lt;parameter name=&quot;iorFilePath&quot;&gt;/path/to/a/new/file&lt;/parameter&gt;</pre></div>
</section>
</html>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>Copyright &copy;2004&#x2013;2021
<a href="https://www.apache.org/">The Apache Software Foundation</a>.
All rights reserved.</p>
</div>
</div>
</footer>
</body>
</html>