function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
priyanka.mv26priyanka.mv26 

Integrating apex with NetDocuments

I am trying to access NetDocuments API from Salesforce. 
I am not sure how do we maintain session between successive calls to API.
Please let me know if you could help me out.
Thanks in advance.
Best Answer chosen by Admin (Salesforce Developers) 
priyanka.mv26priyanka.mv26

Thank you very much for your reply.. 

 

I fixed the session maintenance problem. I modified the line

 

stor.inputHttpHeaders_x.put('Cookie', 'name=value'); 

 

as

 

stor.inputHttpHeaders_x.put('Cookie', 'mycookie =' + cookieop);

 

Now it is invoking the Search function.

 

But now my problem is..

The search function is returning the response as 

 

<storageList>

              <storageObject id=”/abc/h/t/g/i/~031014163114506.nev” location=”c:\temp\contract.doc” visId=”2343-5823-3820” checkedOut=”Y”/>

              <storageObject id=”/abc/p/m/s/i/~031014162932566.nev” location=”c:\temp\Jones Deposition.doc” visId=”4283-2834-3485” checkedOut=”Y”/>

       </storageList>

 

But my WSDL2Apex class has no definitions for the tag storageList and storageObject and hence it is showing the error below

Web service callout failed: Unable to parse callout response. Apex type not found for element storageList 

 

Please help... Thank you very much in advance..


All Answers

Sudhakar ReddySudhakar Reddy

Are u using Webserives API or Rest servies API to access .Net?

priyanka.mv26priyanka.mv26

Yes..

marriottmurdockmarriottmurdock

Hi,

 

NetDocuments APIs are client SOAP and interactive.  They are available at: https://support.netdocuments.com/index.php?/Knowledgebase/List/Index/10/netdocuments-apis  Additionally, you can email email@support.netdocuments.com with additional questions.

 

Best Regards,

Marriott

marriott@netdocuments.com

priyanka.mv26priyanka.mv26

Hi marriottmurdock,

 

Thanks for your reply...

 

Below is my controller code..

 

public with Sharing class DisplayNetDocsFiles_Controller
{
public netdocumentsComNdapi1.SearchResult_element res { get; set; }

public string cookieop {get;set;}

public string myHeader {get;set;}
public string sessionid {get; set;}

netdocumentsComNdapi.LoginResponse_element response_x;
netdocumentsComNdapi.DirectorySoap ndapi;
public DisplayNetDocsFiles_Controller(ApexPages.StandardController controller)
{

ndapi = new netdocumentsComNdapi.DirectorySoap();
ndapi.outputHttpHeaders_x = new Map<String, String>();
ndapi.Login('username','passwd');
cookieop = ndapi.outputHttpHeaders_x.get('Set-Cookie');
myHeader = ndapi.outputHttpHeaders_x.get('My-Header');

netdocumentsComNdapi1.ArrayOfString aos = new netdocumentsComNdapi1.ArrayOfString();
aos.string_x = new string[]{'lastmodified'};

netdocumentsComNdapi1.storageSoap stor = new netdocumentsComNdapi1.storageSoap();
string criteria = '=3(' + 'CA-810623' + ') =10([' + 'NG-6226HXIP' + '])';
stor.inputHttpHeaders_x = new Map<String, String>();
stor.inputHttpHeaders_x.put('Authorization',cookieop);
stor.inputHttpHeaders_x.put('Cookie', 'name=value');
stor.inputHttpHeaders_x.put('myHeader', 'myValue');
res = stor.Search(criteria, aos);

}

}

 

The steps I followed are

1. Downloaded Directory, Storage WSDL from NetDocuments

2. Created WSDL2Apex classes named netdocumentsComNdapi1 and netdocumentsComNdapi from Storage and Directory WSDL repectively.

3. Written the above code to invoke search function in NetDocuments

4. Now my problem is when I invoked login method, login is successful and sessionID is generated.

5. I am not able to maintain the session in the next successive calls like search in my above code.

 

The error message I received is 

 

Web service callout failed: WebService returned a SOAP Fault: Server was unable to process request. ---> No authentication session. The authentication session has timed out or was not established prior to this call. faultcode=soap:Server faultactor=

 

 

Anybody please help.. 

 

marriottmurdockmarriottmurdock

I'll have Bradlee Duncan (bduncan@netdocuments.com) respond, as he knows our APIs better than I. 

BradleeBradlee

I believe you're trying to link a SOAP session to a web session using the user's web server. With that assumption, there are at least two options.

 

The easier route would be to place the SOAP session cookies in the user's cookies for the web requests, and use those on the controller side, if they are present (or kick off a new session if they are not). However, we only recommend this method if the user is using SSL. If they are not using SSL, this method could compromise the security of their account.


The slightly more difficult, but more secure route would be to store the SOAP session cookies on the webserver; an appropriate place might be in the webserver's session database.

 

Let me know if you have additional questions or need clarification.

 


priyanka.mv26priyanka.mv26

Thank you very much for your reply.. 

 

I fixed the session maintenance problem. I modified the line

 

stor.inputHttpHeaders_x.put('Cookie', 'name=value'); 

 

as

 

stor.inputHttpHeaders_x.put('Cookie', 'mycookie =' + cookieop);

 

Now it is invoking the Search function.

 

But now my problem is..

The search function is returning the response as 

 

<storageList>

              <storageObject id=”/abc/h/t/g/i/~031014163114506.nev” location=”c:\temp\contract.doc” visId=”2343-5823-3820” checkedOut=”Y”/>

              <storageObject id=”/abc/p/m/s/i/~031014162932566.nev” location=”c:\temp\Jones Deposition.doc” visId=”4283-2834-3485” checkedOut=”Y”/>

       </storageList>

 

But my WSDL2Apex class has no definitions for the tag storageList and storageObject and hence it is showing the error below

Web service callout failed: Unable to parse callout response. Apex type not found for element storageList 

 

Please help... Thank you very much in advance..


This was selected as the best answer
priyanka.mv26priyanka.mv26

Finally I am done with Integrating NetDocuments with SF using NetDocuments API..

 

Thanks for your response...

priyanka.mv26priyanka.mv26

Now I am facing another issue..

 

I am trying to create a document in NetDocuments through API.. 

 

I invoked create method and it is creating document in NetDocs..

 

But I am unable to open the document.. Please help.. 

 

Thanks in advance...