how to call .net dll in JMeter - java

Can we invoke .net dll in JMeter. I have a peice of code written in .net need to use its output in jmeter as a parameter. (I am trying to call .net writen code which generate a key in jmeter.) Can anyone please help?

If .net dll exposes the COM interface, java can talk to that. If you can do something in java, then JMeter can do that as well.
Check this library which cna access COM interface.
Check this as well for examples: http://danadler.com/jacob/
But is that something which can be done only in .net? If possible, create the lib in java.

There are following options ordered by my personal preferences perspective
Re-implement your .NET code in Java/Groovy using JSR223 Sampler
Compile your code into an executable binary and call it using OS Process Sampler
Use JSR223 Sampler mentioned in step 1 and a wrapper library like jni4net, but keep in mind that you will need a .NET Runtime (Windows with installed .NET Framework or Linux/MacOSX with installed Mono)

Related

Jython can not use lxml library

I'm trying to use zeep library to provide soap call in python code and its okay it works when I try to run with python. Then, I'm trying to use jython to run this code (i need jython because next step will be on the server that uses jython to compile) and when I try to install lxml for jython it gives me this error:
error:Compiling extensions is not supported on Jython
When I search for this situation, I found that jython doesn't support c based libraries.
So, there is a solution with jython-jni bridge but I couldn't understand how to be.
Is there another solution? Or can you give me an obvious example?
I couldn't achieve to implement jni but i created a new layer between jython and server.I mean, i made a REST call from jython compiler and this call listens my server for soap call and it worked.

How to include Java test libraries in a Python based Robot framework

I am trying to get a Robot framework in place based on Python.
On one side of the test block box is a Python simulator for which I have written test libraries to interact with. On the other side there is a Java library.
I have the following questions on how to interact with Java classes from within the Python based Robot framework:
Option A:
Robot Framework (based on Python) includes both the Python test libraries and Java test libraries seamlessly. After reading through the Robot documentation I do not believe this is possible? Or maybe it’s possible and not clearly mentioned anywhere? My understanding is the user needs Jython in order to include the Java classes in the Robot framework but I am currently using Python.
Option B:
Use the Python test library and include the Java classes using JNI and any possible options (py4j, pyjnius, javbridge etc).
Option C:
I am currently calling the Java executable from within the Python test library with the required option (more like a CLI) and then parsing the logs to match for the test in question.
The last option is working but I would like to know the best approach between these three.
To directly use keywords written in java, you'll need to use jython.
Another option is to use the remote library interface. You set up a little XML-RPC server (in java), then import the library by giving robot the address of the server.
The good news is that someone has already written a java based server. See https://github.com/ombre42/jrobotremoteserver

Executing C# Script in Java

I have a little C# script that I created that gets some system information. I was wondering if there is a way to use the C# script without creating an exe and running the exe from it. I have it setup so it will pull information from executing the exe but I would like something a little more generic and doesn't rely so much on the exe but on the C# script itself.
Take a look at http://www.ikvm.net/.
IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework. It includes the following components:
A Java Virtual Machine implemented in .NET
A .NET implementation of the Java class libraries
Tools that enable Java and .NET interoperability

Java Projects on Django?

ok, So i searched net for the possible implementation but all that I managed to find is Django projects implementation on Java platform through Jython. But I want to do the reverse, i.e. implement/integrate java project ( which in my case is SAIKU server ) on Django platform.
The question being, is it possible, and if yes, then kindly point me to the solution.
Thanking in advance =)
For your specific requirement, I would suggest using RESTFul API to access the Saiku Server.
However if you need to run Java Classes from Python.
Here are the options available for you:
JCC -- a C++ code generator for calling Java from C++/Python. It produces producing Python extensions which communicate via JNI with a Java virtual machine. As it implies, this would require compilations of every possible call. However this project is backbone of PyLucene project.
CodeMesh. C++ code generator for Java.
Py4J Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine.
JPype allow python programs full access to java class libraries. It is done through interfacing at the native level in both Virtual Machines. However there are no recent development in this front.
In general, having an loosly coupled integration through REST or RCP would be easy to maintain than tightly coupled JNI based implementation.
There's no way to run Java within the Python runtime (which is what it sounds like you want). There are Java to Python "translators" available, but they're terrible. Honestly, if you need a Java server and Django to sit inside the same process for some reason, Jython is the way to go.
There are lots of options outside of that though, off the top of my head:
Implement Python bindings for your server (See PyLucene for an example)
Implement a socket server within your Java server that Python can talk to directly

Php/Java Integration

Have you experience of integration of php and Java? I've written a class in Java "Hello". Now I want to call its method from php when I create an instance of this class from php with
$obj = new Java(Hello);
Then it gives me fatal error. I've tried many times to setup php ini variables etc but I couldn't find anything. Please advice me how can I set it up.
Thanks in advance
Reference: http://php.net/manual/en/book.java.php
Have a look at:
PHP-Java Bridge
The PHP/Java Bridge is an
implementation of a streaming,
XML-based network protocol, which can
be used to connect a native script
engine, for example PHP, Scheme or
Python, with a Java virtual machine.
It is up to 50 times faster than local
RPC via SOAP, requires less resources
on the web-server side. It is faster
and more reliable than direct
communication via the Java Native
Interface, and it requires no
additional components to invoke Java
procedures from PHP or PHP procedures
from Java.
Could it be you are just missing the quotes around the Java Class? Also make sure you actually do have a Java VM on the machine you are trying to run the code on and make sure you have properly set up the config options. Also, the Java extension is a PECL extension and has to be installed. It is not part of the native distribution. Furthermore, the extension is considered unmaintained and dead, so you might want to have a look at the JavaBridge suggested elsewhere. Zend Server also brings a JavaBridge.
Check out this article: http://www.devshed.com/c/a/PHP/Using-PHP-with-Java/
They say it's possible (and how to do it). I've never done it, so I can't vouch for it...
In my experience the best way to interact between Java and PHP is through a WebService layer. NuSoap for PHP is very good, and you can consume the webservice in Java to create a stub that will build the request/response object.
There are many ways few are:
PHP Java Bridge
Java Integration in PHP
Using web services to pass data in between like SOAP
Using simple HTTP data passage between Java and PHP see (facejar uses the same technique)
Client site script (AJAX)
If you are after security, use option 1 otherwise I prefer using option 4 which is a bit faster when it comes to performance.

Categories