blob: 18f46ec6c819ccbb078d12905e6d5e3f223323f6 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jun 28, 2015 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache Axis2 -
Exposing CORBA Services as Web Services</title>
<style type="text/css" media="all">
@import url("../css/maven-base.css");
@import url("../css/maven-theme.css");
@import url("../css/site.css");
</style>
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
<meta name="Date-Revision-yyyymmdd" content="20150628" />
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="content-type" content="text/html; charset=us-ascii" />
</head>
<body class="composite">
<div id="banner">
<a href="http://www.apache.org/" id="bannerLeft">
<img src="http://www.apache.org/images/asf_logo_wide.png" alt="Apache Axis2" />
</a>
<a href=".././" id="bannerRight">
<img src="../images/axis.jpg" alt="Apache Axis2" />
</a>
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
<span id="publishDate">Last Published: 2015-06-28</span>
&nbsp;| <span id="projectVersion">Version: 1.6.3</span>
</div>
<div class="xright"> <a href="../index.html" title="Axis2/Java">Axis2/Java</a>
|
<a href="http://www.apache.org" class="externalLink" title="Apache">Apache</a>
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>Axis2/Java</h5>
<ul>
<li class="none">
<a href="../index.html" title="Home">Home</a>
</li>
</ul>
<h5>Downloads</h5>
<ul>
<li class="none">
<a href="../download.cgi" title="Releases">Releases</a>
</li>
<li class="none">
<a href="../modules/index.html" title="Modules">Modules</a>
</li>
<li class="none">
<a href="../tools/index.html" title="Tools">Tools</a>
</li>
</ul>
<h5>Documentation</h5>
<ul>
<li class="none">
<a href="../docs/toc.html" title="Table of Contents">Table of Contents</a>
</li>
<li class="none">
<a href="../docs/installationguide.html" title="Installation Guide">Installation Guide</a>
</li>
<li class="none">
<a href="../docs/quickstartguide.html" title="QuickStart Guide">QuickStart Guide</a>
</li>
<li class="none">
<a href="../docs/userguide.html" title="User Guide">User Guide</a>
</li>
<li class="none">
<a href="../docs/jaxws-guide.html" title="JAXWS Guide">JAXWS Guide</a>
</li>
<li class="none">
<a href="../docs/pojoguide.html" title="POJO Guide">POJO Guide</a>
</li>
<li class="none">
<a href="../docs/spring.html" title="Spring Guide">Spring Guide</a>
</li>
<li class="none">
<a href="../docs/webadminguide.html" title="Web Administrator's Guide">Web Administrator's Guide</a>
</li>
<li class="none">
<a href="../docs/migration.html" title="Migration Guide (from Axis1)">Migration Guide (from Axis1)</a>
</li>
</ul>
<h5>Resources</h5>
<ul>
<li class="none">
<a href="../faq.html" title="FAQ">FAQ</a>
</li>
<li class="none">
<a href="../articles.html" title="Articles">Articles</a>
</li>
<li class="none">
<a href="http://wiki.apache.org/ws/FrontPage/Axis2/" class="externalLink" title="Wiki">Wiki</a>
</li>
<li class="none">
<a href="../refLib.html" title="Reference Library">Reference Library</a>
</li>
<li class="none">
<a href="../api/index.html" title="Online Java Docs">Online Java Docs</a>
</li>
</ul>
<h5>Get Involved</h5>
<ul>
<li class="none">
<a href="../overview.html" title="Overview">Overview</a>
</li>
<li class="none">
<a href="../svn.html" title="Checkout the Source">Checkout the Source</a>
</li>
<li class="none">
<a href="../mail-lists.html" title="Mailing Lists">Mailing Lists</a>
</li>
<li class="none">
<a href="../release-process.html" title="Release Process">Release Process</a>
</li>
<li class="none">
<a href="../guidelines.html" title="Developer Guidelines">Developer Guidelines</a>
</li>
<li class="none">
<a href="../siteHowTo.html" title="Build the Site">Build the Site</a>
</li>
</ul>
<h5>Project Information</h5>
<ul>
<li class="none">
<a href="../team-list.html" title="Project Team">Project Team</a>
</li>
<li class="none">
<a href="../issue-tracking.html" title="Issue Tracking">Issue Tracking</a>
</li>
<li class="none">
<a href="http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/" class="externalLink" title="Source Code">Source Code</a>
</li>
<li class="none">
<a href="../thanks.html" title="Acknowledgements">Acknowledgements</a>
</li>
<li class="none">
<a href="http://www.apache.org/licenses/LICENSE-2.0.html" class="externalLink" title="License">License</a>
</li>
<li class="none">
<a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship">Sponsorship</a>
</li>
<li class="none">
<a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">Thanks</a>
</li>
<li class="none">
<a href="http://www.apache.org/security/" class="externalLink" title="Security">Security</a>
</li>
</ul>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="poweredBy" alt="Built by Maven" src="../images/logos/maven-feather.png" />
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<!-- ~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License. --><html xmlns="http://www.w3.org/1999/xhtml">
<h1>Exposing CORBA Services as Web Services</h1>
<div class="section"><h2>Overview<a name="Overview"></a></h2>
<div class="section"><h3>What is CORBA?<a name="What_is_CORBA"></a></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.
</div><div class="section"><h3>What Axis2 CORBA module does?<a name="What_Axis2_CORBA_module_does"></a></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.
<div class="section"><h4>Features<a name="Features"></a></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>
</div></div><div class="section"><h3>Why it is Useful?<a name="Why_it_is_Useful"></a></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>
</div><div class="section"><h2>Tutorial<a name="Tutorial"></a></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.
<div class="section"><h3>Prerequisites<a name="Prerequisites"></a></h3>
<ul>
<li>Sun JDK version 5.0 or higher</li>
<li>Latest version of Axis2 with Axis2 CORBA module</li>
</ul>
</div><div class="section"><h3>Creating the IDL file<a name="Creating_the_IDL_file"></a></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 <tt>calculator.idl</tt>.
<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>
</div><div class="section"><h3>Creating the CORBA server<a name="Creating_the_CORBA_server"></a></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 <tt>calculatorImpl.java</tt> 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 <tt>Server.java</tt> 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>
</div><div class="section"><h3>Creating the CORBA web service<a name="Creating_the_CORBA_web_service"></a></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 <tt>calculator.xml</tt> 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 <tt>http://localhost:8080/axis2/services/Calculator</tt>. The WSDL is located at <tt>http://localhost:8080/axis2/services/Calculator?wsdl</tt>. Now you can create a web service client and use it to invoke methods on the CORBA server.
</div><div class="section"><h3>Additional Configuration details<a name="Additional_Configuration_details"></a></h3>
The service definition file (eg. calculator.xml) supports the following parameters.
<br />
<table border="0" class="bodyTable">
<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 />
</div><div class="section"><h3>Notes:<a name="Notes:"></a></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 <tt>java Server /path/to/a/new/file</tt> to start the server. Remove <tt>namingServiceUrl</tt> and <tt>objectName</tt> properties from the <tt>calculator.xml</tt> 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>
</div>
</html>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">
Copyright &#169; 2004-2015
<a href="http://www.apache.org/">The Apache Software Foundation</a>.
All Rights Reserved.
</div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>