Author Topic: How to use odwek with c# asp.net  (Read 9886 times)

kilvroch

  • Guest
How to use odwek with c# asp.net
« on: August 24, 2015, 09:24:39 AM »
I am new to CMOD and its associated products.
We are storing TIFF images in CMOD, and I wish to view them with a link from an exisitng C# asp.net application.

Can someone please tell me,
Is there an easy way to do this with odwek, or must I use a product such as IKVM to convert the java api to a dll?

by the way, we are using CMOD V9.0,  Windows server 2008, IIS 7
« Last Edit: August 24, 2015, 09:27:45 AM by kilvroch »

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: How to use odwek with c# asp.net
« Reply #1 on: August 24, 2015, 05:04:48 PM »
The only supported method for ODWEK API programming for CMOD is via Java.  I don't know what IKVM is, but you'll probably save yourself a tremendous amount of effort (especially debugging) by working in Java.

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

kilvroch

  • Guest
Re: How to use odwek with c# asp.net
« Reply #2 on: August 25, 2015, 02:18:15 AM »
rewriting an entire existing application in java just to be able to call a java api is NOT an option

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: How to use odwek with c# asp.net
« Reply #3 on: August 25, 2015, 02:40:42 AM »
Maybe it's easier for you to use the arsdoc command to do queries and retrievals?  That can be called from the command line on Windows, but it has almost zero functionality, and the speed would be terrible.

I'm not a C# / Java programmer, so I don't know how to get the two talking.  (Honestly, this is the first I've heard of someone using C# in several years.)  I'm sure there's a way to write some sort of abstraction layer, but it seems like a ton of extremely complex work.  There has been talk of CMIS support in CMOD as well, but I suspect that comes through IBM Content Navigator.  Maybe that's the abstraction layer you need.

Good luck!

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
    • View Profile
Re: How to use odwek with c# asp.net
« Reply #4 on: August 25, 2015, 02:42:23 AM »
Hello Kilvroch,

I didn't know IKVM until today :-) so thanks for the information!

That said, by reading the IKVM home page (I've read only 2 minutes  ;) ), you can do it, of course, but you must be aware that ODWEK Java API are not only the ODApi.jar, but also some native libraries linked with JNI, and also the whole ODWEK installation directory.
I mean, when you connect to CMOD, he will need the native libraries, and also the locale directory, and depending on what you need afterwards, it will search some information/data/files in the ODWEK installation directory.
That means you cannot simply, extract the .jar and integrate it in your project, and that's it, you must get the whole package with you, to be officially supported.

Of course you can take only the piece and bits you want, but if that doesn't work, and you want to be officially supported... then you need to install ODWEK on the server you want to use it.
If not, then one of the first thing the support will ask, is to install the ODWEK and test it again!! :-)

So I've read that IKVM works with JNI, but sometimes it can be tricky, how it is with ODWEK and IKVM... no idea!! If you test it and it works, that would be great to give us some feedback!

Hope that helps a little bit
Alessandro
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
    • View Profile
Re: How to use odwek with c# asp.net
« Reply #5 on: August 25, 2015, 02:44:18 AM »
There has been talk of CMIS support in CMOD as well, but I suspect that comes through IBM Content Navigator.  Maybe that's the abstraction layer you need.

I don't find the link anymore, but there is a CMIS support for CMOD without IBM Content Navigator.
In any cases, this CMIS for CMOD implementation is read only. You cannot store/archive documents... just do some queries
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

kilvroch

  • Guest
Re: How to use odwek with c# asp.net
« Reply #6 on: August 25, 2015, 04:49:58 AM »
thanks for the info, Alessandro.... CMIS is new to me... I will go looking...

kilvroch

  • Guest
Re: How to use odwek with c# asp.net
« Reply #7 on: August 26, 2015, 05:05:52 AM »
I have played with the arswww.cgi script and believe that it will do exactly what I need


Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: How to use odwek with c# asp.net
« Reply #8 on: August 26, 2015, 06:18:38 AM »
I have played with the arswww.cgi script and believe that it will do exactly what I need

I can't stress enough that it's a terrible solution -- deprecated, slow, puts excessive load on the server, limited, between few and no updates...  However, out of a table full of bad solutions, it *is* one that you might be able to get working.

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
    • View Profile
Re: How to use odwek with c# asp.net
« Reply #9 on: August 27, 2015, 01:11:07 AM »
I have played with the arswww.cgi script and believe that it will do exactly what I need

NOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Do whatever you want, but DO NOT USE arswww.cgi for ANY NEW DEVELOPMENT.
The support for that little piece is dead, the current state of this module is V8.4.... it has NO support for the new concept of V8.5, V9.X... it cannot display the new date format of CMOD V9.X, it cannot support Cabinets, Holds....
In addition to that, this piece of code has been declared with CMOD V8.5 (or was it V9?) DEPRECATED by IBM... meaning that it will disappear... It is even possible, that in the next version of CMOD (V9.5.1/V9.6 or V10, depending on how the IBM marketing is going to choose)... it might be possible that this piece will not be there anymore.

If you want, you can write a "arswww.cgi" in Java, and then call the services from C#, exactly like arswww.cgi, but for god sakes... do not use arswww.cgi now... or ever...
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: How to use odwek with c# asp.net
« Reply #10 on: August 27, 2015, 06:13:16 AM »
*laugh*

Never before has so much total and complete despair been unleashed on the ODUG Forums!

Thanks for the laugh, Alex!  :)

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

kilvroch

  • Guest
Re: How to use odwek with c# asp.net
« Reply #11 on: August 27, 2015, 09:14:25 AM »
thanks, Alessandro... I did read where it said the cgi is no longer supported and only exists for historical reasons.  I have not been able to get it to display an image, anyway.
We have an exisiting asp.net application which runs with sql server database of  retail banking information (cheques and credits). We wish to make a call to CMOD to retrieve and display an image in a viewer when a user selects a specific item.
What is the best way?
Can I do that with the servlets?
I have found this page http://www.oracle.com/technetwork/articles/javase/appletaspintegration-141915.html#source

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
    • View Profile
Re: How to use odwek with c# asp.net
« Reply #12 on: August 27, 2015, 11:13:59 PM »
Yep, that could be an idea.

Here is a skeleton of a servlet, that you can use.

I've done it in 5 minutes, so it is absolutely not optimized, and absolutely not production robust, just enough for a proof of concept... but at least it gives you an idea how it might work.
I haven't tested it, so it might contain some bugs :-D

Code: [Select]
package cmod.servlet.sample;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.edms.od.ODConfig;
import com.ibm.edms.od.ODConstant;
import com.ibm.edms.od.ODFolder;
import com.ibm.edms.od.ODHit;
import com.ibm.edms.od.ODServer;

@WebServlet("/RetrieveImage")
public class RetrieveImage extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
getImage(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
getImage(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}

private void getImage(HttpServletRequest request, HttpServletResponse response) throws Exception {

String docID = request.getParameter("doID");
if (docID == null || docID.equals("")) {
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
out.write("No valid parameter given");
out.close();
return;
}

ODConfig odc = new ODConfig();
ODServer ods = new ODServer(odc);
ods.setServerName("localhost");
ods.setPort(1445);
ods.setUserId("admin");
ods.setPassword("ONDEMAND");
ods.initialize("");
ods.logon();

ODFolder odf = ods.openFolder("myFolder");
odf.getCriteria("CMOD_DocID").setOperator(ODConstant.OPEqual);
odf.getCriteria("CMOD_DocID").setSearchValue(docID);
Vector<ODHit> results = odf.search();

if (results.isEmpty()) {
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
out.write("No image found for the docId='" + docID + "'");
out.close();
return;
} else {
ODHit image = results.firstElement();
response.setContentType(image.getMimeType());
byte[] retrievedImage = image.retrieve(ODConstant.NATIVE);
ServletOutputStream out = response.getOutputStream();
out.write(retrievedImage);
out.close();
}
ods.logoff();
ods.terminate();
}
}

Then you run this servlet like that   http://hostname:port/rootContext/RetrieveImage?docID=12345678

Hope that helps a little bit :-)

And yes, this is java... but if you can create a webservice in Java, and call these webservices from C# then you should be ok. Or is it not possible for your C# project?
« Last Edit: August 27, 2015, 11:17:56 PM by Alessandro Perucchi »
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

kilvroch

  • Guest
Re: How to use odwek with c# asp.net
« Reply #13 on: August 28, 2015, 02:24:57 AM »
thanks, I will play with this today
(I'm also fighting with the fact I cannot update JRE on my development machine beyound 7.65 because of old software which must still be allowed to run)