Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LAPI and Servlets

Status
Not open for further replies.

hanreb

Technical User
Jan 23, 2008
90
US
I am looking to get some help in using LAPI with servlets. I want to upload some documents into livelink thru LAPI and HTTP tunnel.

Please advice how to get info on doing this.

I am pasting the code that I developed to do the same.But gives the error, could not access server : com.opentext.api.LLCouldNotConnectHTTPException

I downloaded tomcat , which is on port 8080.

Please Advice.

Below is my code
****************

import java.io.*;
import java.util.*;
import java.text.DateFormat.*;
import com.opentext.api.*;

public class tryServlet
{


private static String Server = "hqp-as-llapdv01"; //livelink host
private static int Port = 2099; //livelink server port see opentext.ini
private static String DFT = ""; //default database file or schema
private static String User = "Admin"; //username
private static String Pass = "password here"; //passwd
public static void main (String args[])
{

//LLSession session1;
LAPI_DOCUMENTS doc;

//session1 = new LLSession (Server, Port, DFT, User, Pass);

// Grab some value objects
LLValue entInfo = (new LLValue()).setAssocNotSet();
LLValue createInfo = (new LLValue()).setAssocNotSet();
LLValue objectInfo = (new LLValue()).setAssocNotSet();
LLValue versionInfo = (new LLValue()).setAssocNotSet();
// Category stuff
LLValue catID = (new LLValue()).setAssocNotSet();
LLValue catVersion = new LLValue();
LLValue attrValues = new LLValue().setList();
LLValue defaultValues = new LLValue().setList();
int status;
LLValue objID = new LLValue().setAssoc();
LLValue attrValPath = new LLValue();
LLValue categories = new LLValue().setList();
LLValue cRequest = new LLValue().setAssoc();
LLValue extData = new LLValue().setAssoc();
LLValue attrInfo = new LLValue();
int volumeID=0;
int objectID=0;
int docObjectID=0;
// Instantiate config Assoc
LLValue config = new LLValue();
config.setAssoc();
// Set config Assoc value
config.add( "HTTPS", LLValue.LL_FALSE );
config.add( "LivelinkCGI", " );
config.add( "HTTPUserName", "tomcat" );
config.add( "HTTPPassword", "s3cret" );
// Instantiate session
LLSession session = new LLSession( " 8080, "","Admin", "passwod here", config );
doc = new LAPI_DOCUMENTS (session);
LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);
LAPI_ATTRIBUTES attributes= new LAPI_ATTRIBUTES (session);
try{
if(doc.AccessEnterpriseWS(entInfo) != 0)
{
System.out.println("AccessEnterpriseWS Failed.");

return;
}
//Grab the info from entInfo
volumeID = entInfo.toInteger("VolumeID");
objectID = entInfo.toInteger("ID");
System.out.println("Volume"+volumeID+"ObjID"+objectID);
catID.add("ID", 874264);
catID.add("Version", 1);
//Use the catID to fetch the category Version
if (doc.FetchCategoryVersion(catID, catVersion) != 0)
{
System.out.println("FetchCategoryVersion Failed.");
return;
}
System.out.println("where r u ?");
attrValues.add("Started");

if (attr.AttrSetValues(catVersion, "Status", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
{
System.out.println("AttrSetValues Failed here.");
}
categories.add( catVersion );
//Fill createInfo to spec (see documentation for the structure)
cRequest.add("Comment", "");
createInfo.add("request", cRequest);
createInfo.add("extendedData", extData);
createInfo.add("Categories", categories);
if(doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,
doc.DOCUMENTSUBTYPE, "logfile.txt", createInfo, objectInfo) != 0)
{
System.out.println("CreateObjectEx Failed.");
System.out.println("Status Code: " + session.getStatus());
System.out.println("Api Error: " + session.getApiError());
System.out.println("Error Message: " + session.getErrMsg());
System.out.println("Status Message: " + session.getStatusMessage());
// return;
}
else
{
System.out.println("Document Object created successfully:Next we have to add a version to complete it");
}
docObjectID = objectInfo.toInteger("ID");
//Now upload version to complete document creation
if(doc.CreateVersion(volumeID, docObjectID, "c:\\temp\\tlist.txt", versionInfo) != 0)
{
System.out.println("CreateVersion Failed.be sure to remove the 0 byte stub in livelink if this happens");
return;
}
else
{
System.out.println("Version created successfully");
}
objID.add("ID",docObjectID);
System.out.println("out of if");
}catch(Exception ex) {

System.out.println("in catch "+ex);
}

} //Main ends
}//Class ends

************

Thanks,
Sunu
 
what has tunneling go to do with servlets ?
If this is a livelink running servlet code then the tomcat url will be something ending in livelink correct there is no exe cgi for that.

First as the lapi user your code is trying you have to hit the URL
context>/livelink if you see a user login and password screen here this means that there in no DirSvcs or SSO on this server so the config assoc that you are setting up is of no use.

The config assoc is needed because you are authenticating to a webserver with DS enabled so you are authenticating to the livelink webserver and having authenticated your part the webserver is redirecting it to the livelink app server that is why the config assoc is important.



Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
I forgot to say this for all lapi connection problems download a utility called "Lapi Test Connection" utility from the OT KB knowledge.opentext.com .That has every permutation/combination of how the session constructor is made.I use that to debug many SSO/LAPI problems and is a very invaluable tool.I have a feeling that you have a internal SSO livelink and a SEA servlet livelink sitting outside the firewall and you are trying to get into the internal livelink thru the SEA server.Frankly I have never attempted that but I would think it should be possibl.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thank you for the reply.
I am still lost.
First ,I am trying to connect to livelink thru my java LAPI code using http tunneling as below.

It gives error could not connect to server.
What could be the reason.

I downloaded LAPI Test Connection utility, but could not figure out the problem .



// Instantiate config Assoc
LLValue config = new LLValue();
config.setAssoc();

2 // Set config Assoc value
config.add( "HTTPS", LLValue.LL_FALSE );
config.add( "LivelinkCGI", "/livelink/livelink.exe" );
config.add( "HTTPUserName", "tomcat" );
config.add( "HTTPPassword", "s3cret" );

3 // Instantiate session LLSession session = new LLSession( " 8080, "", "LivelinkUserName", "LivelinkPassword", config );

Any help please ?
 
Here's a csharp sample that works in this case

It is an Intranet livelink
Livelink is hosted on IIS
IIS has IWA on
Livelink is configured to run with DirSvcs so people are authenticated by the basis of their login.means they will not see a login screen.

I am not sure what your java code is trying to do.Tunneling means that you are not calling livelink on its lapi port such as 2099 to create a session so you need the mechanism of a webserver to "tunnel" you in.So without those pre-conditions calling a webserver does not make any sense.

In that case in my code what I am doing is this

//For HTTP Connection***********************************
String Server = "255.255.255.1"; //the livelink server IP or a DNS name for the web server
int Port = 80; //We are hitting the web server
String DFT = "";
String User = "domain\\zknn1";//submit domain or you could get it from windows
String Pass = "password"; //the correct password not needed dummy will suffice
LLValue config = new LLValue().setAssoc();
config.add("HTTPS", 0);
config.add("LivelinkCGI", "/HOULivelinkTest/llisapi.dll");
config.add("EnableNTLM", 1);
config.add("HTTPUserName", "");//Putting my ad username here did not work
config.add("HTTPPassword", "");//Same as above
session = new LLSession(Server, Port, DFT, User, Pass, config);

If you want to take a look at the full code it is here...






Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Hi,
Sorry to disturb you again. I am not sure if I need to do tunelling or not.

Below is what I want to achieve and not been able to get there.
I have an external application, which is outside of livelink.
I want to write a servlet there and from that servlet I need to connect to livelink and upload documents into livelink.
Not sure how to make that connection from external servlet to livelink ?

Thanks,
Sunu
 
Describing the requirement again,

I have an HTML form with a text field browse button and a submit(Upload to livelink) button.
Using browse I will select a doc from local file system, on clicking the Upload to livelink button a servlet will be invoked in which I need to have the code to connect to livelink and upload the document to livelink.

-Sunu
 
About five years back I toyed with this faq
It is a rudimentary example of a jsp interacting with livelink(not the java livelink plain vanilla livelink).As far as your requirement is considered,livelink also has a product called webforms and that can be used in the context of a workflow to load files into the workflow's attachments area.This form will be served form the livelink server so you are already connected to it.
In any case to talk to livelink,your servlet,cgi or whatver code should have a mechanism to talk to the livelink app server tunneled or not tunneled.I belive having the lapi client libraries on the machine/webserver that has this form should be able to make a connection more or less like the jsp approach I link above.


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 

Thanks for the reply. I will try that over the week end.

Happy Onam .....

-Sunu
 
Hello,

Below is the do post of my servlet.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();


int ErrStatus; //to hold error number of API message
String DFT = ""; //Default database conn.Default systems should work without anything
String User = "Admin"; //username
String Pass = "SAPpassword"; //passwd
String Server = "hqp-as-llapdv01"; //livelink host
int Port = 2099; //livelink server port see opentext.ini
LLSession mySession;//create a session object
LAPI_DOCUMENTS myDoc;//create a document api object
LLValue pwsInfo = (new LLValue()).setAssocNotSet();
LLValue value = new LLValue();//create an LLValue object to store Ent volid


out.close();
}
///Code ends.
When I run the program I get the error as below.
java.lang.NoClassDefFoundError: com/opentext/api/LLValue

Looks like its not recognising LLValue in my servlet code, b.

But in my LAPI java program, which connects to Livelink and uploads doc to livelink it works fine.
There is no problem with LLValue.

What could be the problem ??

Thanks in advance
-Sunu
 
it could be your classpath.The LLVALUE comes if it can access the lapi.jar file

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thank you for the reply.



I had LAPI.jar in my class path for the project, but when I run the project as a web application from eclipse the LAPI.jar was not getting added into the .war file package.
I added lapi.jar manually into WEB-INF/lib folder and it started recognizing the LLValue.

Now inorder to upload document to find the vlumeID and object id I have the below code,

volumeID = entInfo.toInteger("VolumeID");
objectID = entInfo.toInteger("ID");

Here I am getting the error like its not able to recognize “VolumeID”.
The error is as below :

com.opentext.api.LLUnknownFieldException: LLValue unknown field name: VolumeID.

Could you please help....

Thank You,
Sunu
 
Sorry to bother you.
I figured out the problem.
Thank You,
sunu
 
Good Luck and hopefully you now know enough about tunneling as well.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top