I am looking for some direction on calling a C function from within a component. I have looked at the sample C API code in my EnterpriseServer5/samples/c_api but have a gap in understanding.
The integration requires every flat file exchanged between two servers to be subjected to a C function which verifies its contents. The C function uses the file’s contents to generate a 4-character value. After creating the flat file on my source machine, I need to call the C function to create this 4-character value.
I don’t care how the C function returns the 4-character code to the Broker – it can be as request-reply (Publish and Wait) or publish-subscribe. I just need to get the results.
From looking at the C API sample code, I don’t see how to actually call my C function. I also don’t know where the code for the C Client should reside.
First of all is the component from which you need access to the C function is an Integration Component or is it a custom made component? I am guessing that it is the former.
Integration Components are compiled as java classes. Therefor one option you have is to use Java Native Invocation (JNI). You’ll have to look up how to use JNI to invoke a C-function.
An alternative to using JNI that might be quicker is to just build a very small c program that makes use of your c function and the c API provided by wM. You would in effect build a very small c adapter that subscribes to one event, calls the c function, gets the result, and publishes the result in an event. In the integration component you would use a request/reply call to get the information.
Good luck and please let us know how you solved the problem.
Good that I found this discussion as I am facing a similar problem as well. I am trying to call a C Fn from a EJB/COM component and looking at the possibility of going thru the EAI layer for openness. To make the problem a lil more complex, I have over 100 functions and wondering how to make this work!!!
Any help is highly appreciated.
Thanks.
We eventually wrapped our C code in Java and then imported it as a JAR file using the Adapter Configuration tool. This way, the C code could operate within an existing (or new) adapter.
To make this work, we set the LIBRARY PATH to be the path of our C code and we set the CLASSPATH to include our JAR. Not sure if this is redundant, but it works.
Then, within our components, we included an import statement (i.e. Import OurJar) and then used Custom Code steps to invoke our C functions via method calls.