What is Docusign?DocuSign® is The Global Standard for Digital Transaction Management. Accessible anytime, anywhere on any device, global enterprises, business departments, individual professionals, and consumers in all industries solve their paper problems by replacing manual, paper-based methods with DocuSign. The result is accelerated transactions that increase speed to results, reduce costs, improve visibility and control, and delight customers. DocuSign helps you keep business digital with the easiest, fastest, most secure way to send, sign, manage and store documents in the cloud.
Why Docusign?
Check More about Docusign
Sample servlet code to get Docusign account information.
Sample Response:
Download Sample Code
Check More about Docusign
Sample servlet code to get Docusign account information.
package com.kishore.salesforce.docusign;
/**
* Docusign integration
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(name = "com.kishore.salesforce.docusign.GetDocusignAccountInfo", label = "AEM Docusign - GetDocusignAccountInfo", immediate = true, metatype = true)
@Service
@Properties({ @Property(name = "service.description", value = "Get Docusign Account Info"),
@Property(name = "service.vendor", value = "AEM Quickstart"),
@Property(name = "docuserviceurl", value = "https://demo.docusign.net/restapi/v2/login_information"),
@Property(name = "docuusername", value = "xxxxx@gmail.com"),
@Property(name = "docupassword", value = "XXXXXX"),
@Property(name = "sling.servlet.paths", value = "/services/docusign/GetDocusignAccountInfo", propertyPrivate = true),
@Property(name = "sling.servlet.methods", value = "POST"),
@Property(name = "integratorkey", value = "xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx") })
public class GetDocusignAccountInfo extends SlingAllMethodsServlet implements Serializable{
/** The log. */
private Logger log = LoggerFactory.getLogger(GetDocusignAccountInfo.class);
/**
*
*/
private static final long serialVersionUID = 1L;
private String serviceUrl;
private String serviceBaseUrl;
private String userName;
private String password;
private String integratorkey;
private String proxyurl;
private String proxyport;
private String accountid;
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException
{
doPost(request, response);
}
public void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException {
log.info("doPost Started");
log.info("serviceUrl :" + serviceUrl);
log.info("userName" + userName);
log.info("password " + password);
log.info("integratorkey:" + integratorkey);
log.info("serviceBaseUrl: "+serviceBaseUrl);
JSONObject obj = new JSONObject();
String finalUrl=null;
try {
obj.put("Username", userName);
obj.put("Password", password);
obj.put("IntegratorKey", integratorkey);
HttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet(serviceUrl);
HttpHost proxy = new HttpHost(proxyurl, Integer.parseInt(proxyport));
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
getRequest.addHeader("X-DocuSign-Authentication", obj.toString());
HttpResponse responseHttp = httpClient.execute(getRequest);
log.info("Status Code" + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
log.info("Docusgin Account details: "+result);
response.setContentType("text/html");
response.getWriter().write(result.toString());
} catch (JSONException e) {
log.error("Json Exception details :"+ e.toString());
} catch (Exception e) {
log.error("Exception details :"+ e.toString());
}
log.info("doPost Ended");
}
/**
* default activate method.
*
* @param context
* the context
* @throws Exception
* the exception
*/
@Activate
protected void activate(ComponentContext context) throws Exception {
log.info("activate method called");
@SuppressWarnings("rawtypes")
Dictionary properties = context.getProperties();
serviceUrl = (String) properties.get("docuserviceurl");
userName = (String) properties.get("docuusername");
password = (String) properties.get("docupassword");
integratorkey = (String) properties.get("integratorkey");
}
}
Sample Response:
{
"loginAccounts": [
{
"name": "AEM Quickstart",
"accountId": "XXXXX",
"baseUrl": "https://demo.docusign.net/restapi/v2/accounts/XXXXXX",
"isDefault": "true",
"userName": "kishore polsani",
"userId": "XXXX-XXXX-XXXXX-XXXXX",
"email": "kishore.polsani@gmail.com",
"siteDescription": ""
}
]
}
Download Sample Code
No comments:
Post a Comment
If you have any doubts or questions, please let us know.