Connect Tridion Net Tcp using java
Reference: jni4net
Problem: Access nettcp connector using java which is a
.Net Component
Solution: We can create .Net Wrapper which will use Tridion
Core Service assembly, and we can generate java proxy using jni4net, and we'll consume those java proxies as reference for java application.
First we will create Dot.net Class library project which
will deal with CoreService Assembly
Let’s give name as NetTcpConnector
Add reference TridionCoreService assembly from Tridion Sites
Installation
Now you’ll see reference on projects references
Add System.ServiceModel and System.Runtime.Serialization
assembly to references as shown in image above.
Then we’ll create connector class which will perform Tridion
sites operation on project
We do clean and build we’ll get output dll file
Next step is Generate Java proxy using Jni4net, here are following
steps to achieve it.
We’ll first download jni4net proxy
Place zip file at somewhere in your machine and extract it.
You’ll see folder structure like
Now Open Visual Studio native command prompt tool
Navigate to Jni4Net bin directory to access proxygen.exe
file
And run the command
.\proxygen.exe
../../NetTcpConnector/bin/Debug/NetTcpConnector.dll -wd ../../jni4net-wd -dp
../../NetTcpConnector/bin/Debug/Tridion.ContentManager.CoreService.Client.dll
Where –wd is working directory which keeps generated build file
after executed proxygen.exe
-dp represent dependency dll which is used by
NetTcpConnector.dll
After executing go to working directory
Go to working directory run build.cmd file
Which generated proxy jar and dll file which will be used by
java application
First we copy following files from jni4net lib folder to place
it new folder called Java-jni4net-proxies-references
Also copy generated proxies using jni4net from jni4net
working directory to same folder “Java-jni4net-proxies-references“ which we are
going to use on java application.
Then we’ll place original .dll and core service client dll
to same folder
Now we’ll write java
program which calls dotnet method and provide output on java console
Add jni4net.j-0.8.8.0.jar
and NetTcpConnector.j4n.jar to class path of java application
Now we’ll call GetTridionVersion
method which was implementd on don.net side.
Now we run main.java
We’ll see following console which shows output of GetTridion
Version method
Comments
Post a Comment