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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a document to Livelink using webservices

Status
Not open for further replies.

RajaneeshJM

Programmer
Apr 22, 2014
27
IN
Hi,

I am writing a Java program to add a document to Livelink using webservices. I am using the DocumentManagement webservice. Below is the uploadFile method which accepts DocumentManagement dm as a parameter

private static void uploadFile(DocumentManagement dm, String admToken) {
String name = "TestLivelink.docx";
String comment = "Uploaded through the Web Service";
boolean advancedVersionControl = true;
Metadata metadata = null;
int parentID = 2000;
String contextId;

String filePath = "E:/Livelink/TestUpload/TestLivelink.docx";

try{
File file = new File(filePath);
Attachment atch = new Attachment();
atch.setContents(getByteArray(file));
atch.setFileName(file.getName());
atch.setFileSize(file.getTotalSpace());
atch.setCreatedDate(getXMLGregorianCalendar(new Date(file.lastModified())));
atch.setModifiedDate(getXMLGregorianCalendar(new Date(file.lastModified())));

Node node = dm.createDocument(parentID, name, comment, true, metadata, atch);
System.out.println("node id:"+node.getID());
}catch(Exception e){
System.out.println("Error:"+e.getMessage());
}
}

On execution I encounter the below exception

javax.xml.ws.soap.SOAPFaultException: Error adding version to 'TestRJM.docx'. Error reading data stream from version. [E682033159]

Request you to help me resolve the issue.

Regards
Rajaneesh JM
 
Hi Rajneesh from your posting it is not very clear how the livelink setup is .If you take a step back you should understand that the API (WS) is basically
a conduit into the web application called livelink a.k.a contentserver.So initial trouble shooting should be

1)Is the same file accessible through livelink URL can you add it
2)Can you download SOAPUI and do some simple tests like getting a session
3)is the file large enough so you may have to use a different mechanism(you must have heard MTOM,http ,ContentService). It is in the javadocs of the wsapi.

If the tests rule out your livelink you should do this on the livelink server

Debug=2
[options]
WantLogs=true
WantLAPILogs=true

put that in opentext.ini and re-stsrt and re-attempt.If the problem now is livelink you will see why livelink is complaining in the thread logs.

Your code ppears to be how someone would do that with a java client,but since it is a SOAP fault I suspect something else is at fault.


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Hi Appnair,

Livelink CS10SP2Update 11 is installed on Windows machine using IIS. The webservices are installed on Apache Tomcat.

I am able to add the document using Add Item -> Document option in a different folder in Livelink.

Also I have verified the Authentication from the Java Client using simple sout's. Authentication is successful and also I am able to list the nodes using DocumentManagement service

The file size is only 14kb.

As suggested by you, I have modified opentext.ini and added the below lines at the end of the file. But I could not notice any logs under <OpenTextHome>\logs folder. Is there any particular file I should look at?

Debug=2
[options]
WantLogs=true
WantLAPILogs=true

In the Apache Tomcat server, I have observed the below logs in les-services.log

Livelink error occurred
Status: 903101
Error Code: DocMan.NodeCreationError
Error Message: Error adding version to 'TestLivelink.docx'. Error reading data stream from version. [E682033159]
ApiError: Error reading data stream from version.

Please help me resolve this issue.

Thanks in advance
 
There should have been a key called Debug in opentext.ini it happens in the first 100 lines
Then there should be a section called [options] that is where you would have put the
values if they do not exist.

If you do that and re-start your /logs directory would start showing thread<1-n>.out logs connect<1-n>.out logs
If a lapi or webuser command is received then the input and output is recorded in thread logs and dtabase calls are recorded in connect logs
see how I have made my opentext.ini only relevant sections shown.If the error is sreported in tomcat logs but you cannot find anything corresponding in livelink logs then the
call has not made it to livelink

[general]
version=20
LLIndexRequiresLogin=FALSE
LLIndexHTMLFile=llindex.html
DefaultRH=enterprise.home
DefaultContentRH=Enterprise.Home
Debug=2
Port=2099
Server=localhost



[options]
maxRightsString=250
MaxOpenSessions=100
wantByteServing=FALSE
wantLogs=TRUE
wantLapiLogs=true

wantSecureCookies=TRUE
wantTimings=TRUE
wantVerbose=TRUE
wantWeb=TRUE
WantSummaryTimings=TRUE
EnableAgents=TRUE
EnableAgentsTrace=FALSE
EnableAgentsTestAll=FALSE
EnableNotification=TRUE
wantSearch=TRUE
wantSearchLogs=FALSE
wantHTMLView=TRUE
ObjectRankEnabled=TRUE
categoryNumToUpgrade=5
errorMessageWantDebugInfo=FALSE
wantIcons=TRUE
WantDirectFetch=false
cacheControlHeader=false
EFSCopyBufferSize=524288
RunWithoutLogin=TRUE



Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Hi AppNair,

Thanks for helping me update the opentext.ini.

After change of settings, I restarted the server and executed the java client to add the document again. Below is the log from one of the thread.out files. Please help me in resolving the issue

08/27/2014 17:12:09 [2851869051] Processing Request on socket 0000000013C1E260
08/27/2014 17:12:09
08/27/2014 17:12:09 Wed Aug 27 17:12:09 2014
08/27/2014 17:12:09 Arguments = 'A<1,?,''advancedVersionControl''=false,''comment''=''Uploaded through the Web Service'',''fileAtts''=A<1,?,''CreatedD
08/27/2014 17:12:09 FileAttributes = 'A<1,?,''CreatedDate''=D/2014/8/26:11:6:31,''Creator''=?,''DataForkSize''=L217789231104,''FileName''=''TestLivelink.do
08/27/2014 17:12:09 FilePath = 'TestLivelink.docx'
08/27/2014 17:12:09 ServiceMethod = 'CreateDocument'
08/27/2014 17:12:09 ServiceName = 'DocumentManagement'
08/27/2014 17:12:09 _ApiName = 'InvokeService'
08/27/2014 17:12:09 _ClientVersion = '9.7.1'
08/27/2014 17:12:09 _ConnectionName = ''
08/27/2014 17:12:09 _Cookie = 'MCPOesMwl1Gth%2BodesCqlpH3Pkub5QDkjZerUVhgj%2BuypLnRbyGf3g%2FsTPoPu%2Bt2'
08/27/2014 17:12:09 _DomainName = ''
08/27/2014 17:12:09 _ImpersonateUserDomain = ''
08/27/2014 17:12:09 _LLENVIRON_ASSOC = 'A<1,?,''REMOTE_ADDR''=''192.168.102.104''>'
08/27/2014 17:12:09 _Request = 'llweb'
08/27/2014 17:12:09 _UserName = ''
08/27/2014 17:12:09 _UserPassword = 'XXXXXXXXXX'
08/27/2014 17:12:09 =======================================
08/27/2014 17:12:09 Executing API: #3000257c.InvokeService
08/27/2014 17:12:09 inArgs: A<1,?,'Arguments'=A<1,?,'advancedVersionControl'=false,'comment'='Uploaded through the Web Service','fileAtts'=A<1,?,'CreatedDate'=D/2014/8/26:11:6:31,'FileName'='TestLivelink.docx','FileSize'=L217789231104,'ModifiedDate'=D/2014/8/26:11:6:31,'_SDOName'='Core.FileAtts'>,'metadata'=?,'name'='TestLivelink.docx','parentID'=2000>,'FileAttributes'=A<1,?,'CreatedDate'=D/2014/8/26:11:6:31,'Creator'=?,'DataForkSize'=L217789231104,'FileName'='TestLivelink.docx','FinderFlags'=0,'ModifiedDate'=D/2014/8/26:11:6:31,'Platform'=2,'ResourceForkSize'=0,'Type'=?>,'FilePath'='TestLivelink.docx','ServiceMethod'='CreateDocument','ServiceName'='DocumentManagement','_ApiName'='InvokeService','_ClientVersion'='9.7.1','_ConnectionName'='','_Cookie'='MCPOesMwl1Gth%2BodesCqlpH3Pkub5QDkjZerUVhgj%2BuypLnRbyGf3g%2FsTPoPu%2Bt2','_DomainName'='','_ImpersonateUserDomain'='','_LLENVIRON_ASSOC'=A<1,?,'REMOTE_ADDR'='192.168.102.104'>,'_Request'='llweb','_UserName'='','_UserPassword'='XXXXXXXXXX'>
08/27/2014 17:12:09 ------------------------------------------
08/27/2014 17:12:09 _LLENVIRON_ASSOC contains:
08/27/2014 17:12:09 REMOTE_ADDR=192.168.102.104
08/27/2014 17:12:09 End _LLENVIRON_ASSOC
08/27/2014 17:12:09 Log[0] : Initializing the settings for extractor exclusions.
08/27/2014 17:12:09 CBCreatePre overridden: DateModified [#41e91d1 (DateModified:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: DateCreated [#41e9857 (DateCreated:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: SubTypeType [#41e985d (SubTypeType:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: Owner [#41e98d5 (Owner:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: Modifier [#41e98f2 (Modifier:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: DateCreated [#41ee69c (DateCreated:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: Modifier [#41ee69e (Modifier:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: Owner [#41ee6a0 (Owner:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: Creator [#41ef827 (Creator:lliapi)]
08/27/2014 17:12:09 CBCreatePre overridden: Version [#41ef828 (Version:lliapi)]
08/27/2014 17:12:09 CBCreate overridden: NodeCallbacks [#32000b6f (NodeCallbacks:docmanservice)]
08/27/2014 17:12:09 CBCreate overridden: Recommender Callbacks [#49005965 (Recommender Callbacks:recommender)]
08/27/2014 17:12:09 CBCreate overridden: ComponentNodeCallbacks [#1d05743a (ComponentNodeCallbacks:webnode)]
08/27/2014 17:12:11 0|Folder|restorable|
08/27/2014 17:12:11 128|Workflow Map|restorable|
08/27/2014 17:12:11 130|Topic|restorable|
08/27/2014 17:12:11 131|Category|restorable|
08/27/2014 17:12:11 132|Category Folder|restorable|
08/27/2014 17:12:11 134|Reply|restorable|
08/27/2014 17:12:11 136|Compound Document|restorable|
08/27/2014 17:12:11 137|Release Volume|restorable|
08/27/2014 17:12:11 138|Release|restorable|
08/27/2014 17:12:11 139|Revision|restorable|
08/27/2014 17:12:11 140|URL|restorable|
08/27/2014 17:12:11 144|Document|restorable|
08/27/2014 17:12:11 145|Text Document|restorable|
08/27/2014 17:12:11 146|Custom View|restorable|
08/27/2014 17:12:11 154|Workflow Attachments|restorable|
08/27/2014 17:12:11 202|Project|restorable|
08/27/2014 17:12:11 201|Project Workspace|restorable|
08/27/2014 17:12:11 204|Task List|restorable|
08/27/2014 17:12:11 210|Task List Volume|restorable|
08/27/2014 17:12:11 205|Task Group|restorable|
08/27/2014 17:12:11 206|Task|restorable|
08/27/2014 17:12:11 207|Channel|restorable|
08/27/2014 17:12:11 209|Channel Volume|restorable|
08/27/2014 17:12:11 208|News|restorable|
08/27/2014 17:12:11 212|Milestone|restorable|
08/27/2014 17:12:11 215|Discussion|restorable|
08/27/2014 17:12:11 143|Discussion Volume|restorable|
08/27/2014 17:12:11 218|Poll|restorable|
08/27/2014 17:12:11 298|Collection|restorable|
08/27/2014 17:12:11 299|LiveReport|restorable|
08/27/2014 17:12:11 335|XML DTD|restorable|
08/27/2014 17:12:11 380|Prospector Queries|restorable|
08/27/2014 17:12:11 480|Appearance|restorable|
08/27/2014 17:12:11 482|Global Appearance|restorable|
08/27/2014 17:12:11 483|Appearance Workspace Folder|restorable|
08/27/2014 17:12:11 484|Appearance Folder|restorable|
08/27/2014 17:12:11 543|Project Template|restorable|
08/27/2014 17:12:11 844|Custom View Template|restorable|
08/27/2014 17:12:11 899|Virtual Folder|restorable|
08/27/2014 17:12:11 133|Categories Volume|non-restorable container|
08/27/2014 17:12:11 141|Enterprise Workspace|non-restorable container|
08/27/2014 17:12:11 142|My Workspace|non-restorable container|
08/27/2014 17:12:11 148|System Volume|non-restorable container|
08/27/2014 17:12:11 161|Workflow Volume|non-restorable container|
08/27/2014 17:12:11 162|Workflows Edit Volume|non-restorable container|
08/27/2014 17:12:11 180|Domain Workspace|non-restorable container|
08/27/2014 17:12:11 211|Reports Volume|non-restorable container|
08/27/2014 17:12:11 268|Template Folder|non-restorable container|
08/27/2014 17:12:11 269|Search Manager|non-restorable container|
08/27/2014 17:12:11 270|Data Flow Manager|non-restorable container|
08/27/2014 17:12:11 275|Slice Folder|non-restorable container|
08/27/2014 17:12:11 276|Data Source Folder|non-restorable container|
08/27/2014 17:12:11 290|Backup Manager|non-restorable container|
08/27/2014 17:12:11 336|XML DTD Volume|non-restorable container|
08/27/2014 17:12:11 370|Partition Map|non-restorable container|
08/27/2014 17:12:11 397|My Personal Staging Folders|non-restorable container|
08/27/2014 17:12:11 398|Personal Staging Folder|non-restorable container|
08/27/2014 17:12:11 402|Deleted Documents Volume|non-restorable container|
08/27/2014 17:12:11 405|Deleted Items|non-restorable container|
08/27/2014 17:12:11 481|Content Server Appearances|non-restorable container|
08/27/2014 17:12:11 541|Templates Volume|non-restorable container|
08/27/2014 17:12:11 542|Template Folder|non-restorable container|
08/27/2014 17:12:11 870|My Reserved Items|non-restorable container|
08/27/2014 17:12:11 900|Dynamic View|non-restorable container|
08/27/2014 17:12:11 901|Facets Volume|non-restorable container|
08/27/2014 17:12:11 905|Facet Folder|non-restorable container|
08/27/2014 17:12:11 919|Memcached Folder|non-restorable container|
08/27/2014 17:12:11 1|Shortcut|not restorable|
08/27/2014 17:12:11 2|Generation|not restorable|
08/27/2014 17:12:11 190|Workflow Status|not restorable|
08/27/2014 17:12:11 257|Content Server Search Federator|not restorable|
08/27/2014 17:12:11 258|Search Query|not restorable|
08/27/2014 17:12:11 259|Enterprise Extractor|not restorable|
08/27/2014 17:12:11 260|Proxy|not restorable|
08/27/2014 17:12:11 271|Process|not restorable|
08/27/2014 17:12:11 272|Enterprise Search Federator|not restorable|
08/27/2014 17:12:11 273|Merge|not restorable|
08/27/2014 17:12:11 274|Best Bets|not restorable|
08/27/2014 17:12:11 277|Directory Walker|not restorable|
08/27/2014 17:12:11 278|Search Result Snapshot|not restorable|
08/27/2014 17:12:11 280|Spider|not restorable|
08/27/2014 17:12:11 281|Update Distributor|not restorable|
08/27/2014 17:12:11 282|Document Conversion|not restorable|
08/27/2014 17:12:11 285|XML Activator Producer|not restorable|
08/27/2014 17:12:11 286|XML Activator Consumer|not restorable|
08/27/2014 17:12:11 291|Backup Process|not restorable|
08/27/2014 17:12:11 292|Search Form|not restorable|
08/27/2014 17:12:11 293|Importer|not restorable|
08/27/2014 17:12:11 294|Two Way Tee|not restorable|
08/27/2014 17:12:11 368|Index Engine|not restorable|
08/27/2014 17:12:11 369|Search Engine|not restorable|
08/27/2014 17:12:11 371|Partition|not restorable|
08/27/2014 17:12:11 381|Remote Content Server|not restorable|
08/27/2014 17:12:11 383|Search Results Template|not restorable|
08/27/2014 17:12:11 384|Prospector|not restorable|
08/27/2014 17:12:11 387|Prospector Snapshot|not restorable|
08/27/2014 17:12:11 902|Column|not restorable|
08/27/2014 17:12:11 903|Facet Tree|not restorable|
08/27/2014 17:12:11 904|Facet|not restorable|
08/27/2014 17:12:11 906|Fixed System Column|not restorable|
08/27/2014 17:12:11 920|Memcached Process|not restorable|
08/27/2014 17:12:11 CBDeletePre overridden: UndeleteNodeCallbacks [#4d0001c7 (UndeleteNodeCallbacks:undelete)]
08/27/2014 17:12:11 CBDeletePre overridden: CollectionsCallbacks [#5a001101 (CollectionsCallbacks:collections)]
08/27/2014 17:12:11 CBDeletePre overridden: ComponentNodeCallbacks [#1d05743a (ComponentNodeCallbacks:webnode)]
08/27/2014 17:12:11 CBMovePre overridden: DateModified [#41e91d1 (DateModified:lliapi)]
08/27/2014 17:12:11 CBMovePre overridden: ObjectFacets [#42038b0 (ObjectFacets:lliapi)]
08/27/2014 17:12:11 CBMovePre overridden: AllFacets [#42353f8 (AllFacets:lliapi)]
08/27/2014 17:12:11 CBMovePre overridden: ComponentNodeCallbacks [#1d05743a (ComponentNodeCallbacks:webnode)]
08/27/2014 17:12:11 CBMove overridden: Modifier [#41e98f2 (Modifier:lliapi)]
08/27/2014 17:12:11 CBMove overridden: Modifier [#41ee69e (Modifier:lliapi)]
08/27/2014 17:12:11 CBMove overridden: IndexLibraryNodeMoveCB [#280005d9 (IndexLibraryNodeMoveCB:indexlibrary)]
08/27/2014 17:12:11 CBUpdateUserID overridden: Owner [#41e98d5 (Owner:lliapi)]
08/27/2014 17:12:11 CBUpdateUserID overridden: Owner [#41ee6a0 (Owner:lliapi)]
08/27/2014 17:12:11 Service error occurred
08/27/2014 17:12:11 Error Code: DocMan.NodeCreationError
08/27/2014 17:12:11 Error Message: Error adding version to 'TestLivelink.docx'. Error reading data stream from version. [E682033159]
08/27/2014 17:12:11 Error Details
08/27/2014 17:12:11 - Error reading data stream from version.
08/27/2014 17:12:11 ------------------------------------------
08/27/2014 17:12:11 inArgs: A<1,?,'Arguments'=A<1,?,'advancedVersionControl'=false,'comment'='Uploaded through the Web Service','fileAtts'=A<1,?,'CreatedDate'=D/2014/8/26:11:6:31,'FileName'='TestLivelink.docx','FileSize'=L217789231104,'ModifiedDate'=D/2014/8/26:11:6:31,'_SDOName'='Core.FileAtts'>,'metadata'=?,'name'='TestLivelink.docx','parentID'=2000>,'FileAttributes'=A<1,?,'CreatedDate'=D/2014/8/26:11:6:31,'Creator'=?,'DataForkSize'=L217789231104,'FileName'='TestLivelink.docx','FinderFlags'=0,'ModifiedDate'=D/2014/8/26:11:6:31,'Platform'=2,'ResourceForkSize'=0,'Type'=?>,'FilePath'='TestLivelink.docx','ServiceMethod'='CreateDocument','ServiceName'='DocumentManagement','_ApiName'='InvokeService','_ClientVersion'='9.7.1','_ConnectionName'='','_Cookie'='MCPOesMwl1Gth%2BodesCqlpH3Pkub5QDkjZerUVhgj%2BuypLnRbyGf3g%2FsTPoPu%2Bt2','_DomainName'='','_ImpersonateUserDomain'='','_LLENVIRON_ASSOC'=A<1,?,'REMOTE_ADDR'='192.168.102.104'>,'_Request'='llweb','_UserName'='','_UserPassword'='XXXXXXXXXX'>
08/27/2014 17:12:11 outArgs: A<1,?,'_apiError'='Error reading data stream from version.','_Cookie'='MCPOesMwl1Gth%2BodesCqlpH3Pkub5QDkjZerUVhgj%2BuypLnRbyGf3g%2FsTPoPu%2Bt2','_errMsg'='Error adding version to \'TestLivelink.docx\'. Error reading data stream from version. [E682033159]','_Status'=903101,'_StatusMessage'='DocMan.NodeCreationError','_TimeLogin'='27 08 14 171209'>
08/27/2014 17:12:11 status: DocMan.NodeCreationError (903101)
08/27/2014 17:12:11 msecs: 2953
08/27/2014 17:12:11 =======================================
08/27/2014 17:12:11 Wed Aug 27 17:12:11 2014 - 343208 Func='lapi.InvokeService:DocumentManagement.CreateDocument()' Timing: 2.953 2.965 2.953
08/27/2014 17:12:11 [2854839551] Done with Request on socket 0000000013C1E260

Regards
Rajaneesh JM
 
is this variable in your code
String filePath = "E:/Livelink/TestUpload/TestLivelink.docx";

readable by the livelink server from looking at your code it looks like
you are saying hey livelink server read thge stream that originates in the E drive
is livelink and the client api on the same machine?

verify what the atch variable has before you ares ending the request.

I have nothing further to comment as you say this same code works in another part of your livelink

If I had time I could try your code too busy

Try OT support if you can't fix it by doing some common sense tests





Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Hi AppNair,

My livelink and client are in two different machines. The path mentioned in the filePath variable String filePath = "E:/Livelink/TestUpload/TestLivelink.docx"; is available in the client. The program is being executed from the client machine.

I tried executing the program by providing the path available in the server machine. Even then the result is the same.

I observed one thing from the logs. FilePath only mentions the name of the file and not the path. Does Livelink has a default folder where it expects the file to be placed? Please help me resolve the issue

Processing Request on socket 0000000013C1E260
08/27/2014 17:12:09
08/27/2014 17:12:09 Wed Aug 27 17:12:09 2014
08/27/2014 17:12:09 Arguments = 'A<1,?,''advancedVersionControl''=false,''comment''=''Uploaded through the Web Service'',''fileAtts''=A<1,?,''CreatedD
08/27/2014 17:12:09 FileAttributes = 'A<1,?,''CreatedDate''=D/2014/8/26:11:6:31,''Creator''=?,''DataForkSize''=L217789231104,''FileName''=''TestLivelink.do
08/27/2014 17:12:09 FilePath = 'TestLivelink.docx'
08/27/2014 17:12:09 ServiceMethod = 'CreateDocument'
08/27/2014 17:12:09 ServiceName = 'DocumentManagement'

Regards
Rajaneesh JM
 
Can you tell me one thing do you have access to knowledge.opentext.com so I can point to standard official code as a client programmer you do not have to worry about livelink specifics all you have to make sure is and I keep repeating this and you completely ignore me again

1)can you open up a web browser on your client machine and upload the file if it works your WS API call should work provided you have the same parameters meaning file is the same the location in livelink is the same

What you are getting into is unwanted debugging for what since in my mind you have not told me or this forum simple debugging / common sense ways of looking at a somewhat easy problem

Once again the API has to follow the same business rules in however the DMS is configured to perform

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Hi AppNair,

I have access to knowledge.opentext.com. As mentioned earlier, I am able to upload the document to livelink when connected thru a web browser. The exception is encountered only when adding a document using webservices

Regards
Rajaneesh JM
 
Go to this link

Select the first Graphic that says 'Using CWS'

use the Java sample
Compare your code vs OT code.If the OT code works then chase why your code does not...


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Thanks AppNair.

I will try this link.

Meanwhile, note that I am using CS10.0.0 SP2 Update 11 and the link which you provided is for CS10.5

Hope this version change is not a concern.

Regards
Rajaneesh JM
 
Not as far as I know.All the webservices api is doing is giving you proxies.So long as you are downloading the proxies from a livelink server
that you want to program against you wont have a problem.Suppose OT introduces a new command and puts them only in livelink 10.5(which usually they won't)
if you make your code in 10.5 and try it against 971 or 10 just like that you may run into difficulty.As soon as the IDE is allowed to download the proxies
it will basically mark those calls in red and refuse to compile because for it to work the only way is to understand the code that is in that livelink.
I keep saying this to all upcoming livelink client programmers whether in lapi or wsapi.You are just using a programming language to do something in livelink.It still has to follow livelink business rules which can vary form customer to customer.It has allowed me to be successful once I realized that .
It also does not hurt to understand the flow
User doing a upload using webgui(client browser and livelink server is two entities)
user authenticates,cookie written to browser,user uploads file using File control tag,file is deposited in livelink servers configured area(usually web server temp). This area is basically a place accessible by the livelink service user. Livelink creates the node,and adds the version to the configure storage provider usually a file store accesisible by the livelink service user.If you look the client browser has access to the webserver temp that is how web uploads happen in any application be it streaming or file.
User doing a upload using livelink web services or lapi(client code and livelink server are two entities)
user authenticates,cookie given to client that is your auth token,user uploads file using code ,file is streamed again(lots of ways as explained in the java docs that could go wrong if not done correctly)the wsapi client talks to livelink on the lapi port & server configured in the Web.Config,most usually the CWS server and the livelink server is the same so that localhost:2099 can work) .Note the problems you are having could stem from file permission etc.If I were to look at it closely I would put fiddler of filemon or something that kind,but I would most certainly try OT code and simple things first :)




Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Hi AppNair,

Thanks a lot for your support.

I am able to upload a document using webservices. The link provided by you helped me identify the thing(simple as you say) which I was missing.

Thanks again.

Regards
Rajaneesh JM
 
so what was it ?can you be kind enough to the community and help some other person who is in the same boat.That is how community sites work.You just don't get help and just vanish You are supposed to pay it forward :)

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
You are right AppNair. Here is the sample program. Few extra headers [Method getFileAttsElementHeader] are required when using the uploadContent method available in ContentService.

Earlier, I was trying the createDocument method from DocumentManagement service. In the new logic I am using the createDocumentContext method from DocumentManagement. Using the contextID returned from the method, an instance of ContentService is obtained and then the uploadContent method is used to upload the document. Although I could not identify the reason for failure of createDocument method, I don't mind using the new logic. Atleast I have a solution to upload a document using webservices.

private static void uploadFile(DocumentManagement dm, String admToken) {
String name = "TestLivelink.docx";
String comment = "Uploaded through the Web Service";
boolean advancedVersionControl = false;
int parentID = 2000; //ID of Enterprise Workspace
String contextId;
String filePath = "E:/Livelink/TestUpload/"+name;

try{
File file = new File(filePath);
if(!file.exists()){
System.out.println("File does not exist at "+filePath);
return;
}

contextId = dm.createDocumentContext(parentID, file.getName(), comment, advancedVersionControl, null);
System.out.println("ContextId is "+contextId);

FileAtts fileAtts = new FileAtts();
fileAtts.setCreatedDate(getXMLGregorianCalendar(new Date(file.lastModified())));
fileAtts.setFileName(file.getName());
fileAtts.setFileSize(file.length());
fileAtts.setModifiedDate(getXMLGregorianCalendar(new Date(file.lastModified())));

ContentService contentService = getContentService(admToken, contextId, fileAtts);
String objectID = contentService.uploadContent(new DataHandler(new FileDataSource(file)));
System.out.println("uploaded object Id:"+objectID);

Node node = dm.getNode(Integer.parseInt(objectID));
System.out.println("Node id is:"+node.getID());
}catch(Exception e){
System.out.println("Upload Failed "+e.getMessage());
}
}

public static XMLGregorianCalendar getXMLGregorianCalendar(Date date) throws Exception{
XMLGregorianCalendar xmlCalender=null;
GregorianCalendar calender = new GregorianCalendar();
calender.setTime(date);
xmlCalender = DatatypeFactory.newInstance().newXMLGregorianCalendar(calender);
return xmlCalender;
}

private static ContentService getContentService(String authToken, String contextID, FileAtts fileAtts) throws Exception{
URL url = null;
URL baseUrl = ContentService_Service.class.getResource(".");
if(".NET".equals(NET_OR_JAVA)){
url = new URL(baseUrl, NET_WSDL_LOCATION + "ContentService.svc?wsdl");
} else if("JAVA".equals(NET_OR_JAVA)){
url = new URL(baseUrl, JAVA_WSDL_LOCATION + "ContentService?wsdl");
}
ContentService_Service contentService = new ContentService_Service(url, new QName(CORE_NAMESPACE, "ContentService"));
ContentService endpoint = contentService.getBasicHttpBindingContentService(new MTOMFeature());
OTAuthentication otAuth = new OTAuthentication();
otAuth.setAuthenticationToken(authToken);
setSoapHeader((WSBindingProvider) endpoint, otAuth, contextID, fileAtts);
return endpoint;
}

public static void setSoapHeader(WSBindingProvider bindingProvider, OTAuthentication otAuth, String contextID, FileAtts fileAtts) throws Exception{
List<Header> headers = new ArrayList<Header>();
SOAPMessage message = MessageFactory.newInstance().createMessage();
SOAPPart part = message.getSOAPPart();
SOAPEnvelope envelope = part.getEnvelope();
SOAPHeader header = envelope.getHeader();
headers.add(getOTAuthenticationHeader(header, otAuth));
if(!"".equals(contextID)){
headers.add(getContentIDElementHeader(header, contextID));
}
if(fileAtts != null){
headers.add(getFileAttsElementHeader(header, fileAtts));
}
bindingProvider.setOutboundHeaders(headers);
}

public static Header getContentIDElementHeader (SOAPHeader header, String contextID) throws Exception{
SOAPHeaderElement contextIDElement;
contextIDElement = header.addHeaderElement(new QName(CORE_NAMESPACE, "contextID"));
contextIDElement.addTextNode(contextID);
return Headers.create(contextIDElement);
}

public static Header getFileAttsElementHeader (SOAPHeader header, FileAtts fileAtts) throws Exception{
SOAPHeaderElement fileAttsElement;
fileAttsElement = header.addHeaderElement(new QName(CORE_NAMESPACE, "fileAtts"));
SOAPElement createdDateElement = fileAttsElement.addChildElement(new QName(CORE_NAMESPACE, "CreatedDate"));
createdDateElement.addTextNode(fileAtts.getCreatedDate().toString());
SOAPElement modifiedDateElement = fileAttsElement.addChildElement(new QName(CORE_NAMESPACE, "ModifiedDate"));
modifiedDateElement.addTextNode(fileAtts.getModifiedDate().toString());
SOAPElement fileSizeElement = fileAttsElement.addChildElement(new QName(CORE_NAMESPACE, "FileSize"));
fileSizeElement.addTextNode(fileAtts.getFileSize().toString());
SOAPElement fileNameElement = fileAttsElement.addChildElement(new QName(CORE_NAMESPACE, "FileName"));
fileNameElement.addTextNode(fileAtts.getFileName());
return Headers.create(fileAttsElement);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top