HotDocs Cloud Services Client Libraries

klwilkins edited this page Oct 17, 2013 · 9 revisions

Integration with HotDocs Cloud Services has been simplified by the availability of open-source client libraries written in C#, Java, PHP, and Ruby. Each implementation has its own unique characteristics, as described below.

###C# The C# HotDocs Cloud Services client library is part of the larger HotDocs Open SDK. As such, it can be used via the Open SDK IServices interface, as in the following example. Assuming there is a method MyGetPath(string packageID) that takes a package ID and returns the file path of that package:

var location = new PackagePathTemplateLocation(packageID, MyGetPath(packageID));
IServices svc = Util.GetCloudServicesInterface();
InterviewResult result = svc.GetInterview(new Template(location), null, null, null, null);

Alternatively, the Cloud Services client classes can be used directly. The client classes are RestClient and SoapClient, each of which has methods for getting an interview, assembling a document, and retrieving component information. RestClient has additional methods for creating and resuming HotDocs Embedded sessions, as in the following examples.

Creating a HotDocs Embedded session:

var client = new RestClient("MySubscriberID", "MySigningKey");
var location = new PackagePathTemplateLocation(packageID, MyGetPath(packageID));
string sessionID = client.CreateSession(new Template(location));

Resuming a HotDocs Embedded session:

var client = new RestClient("MySubscriberID", "MySigningKey");
string sessionID = client.ResumeSession(snapshot, id => new PackagePathTemplateLocation(id, MyGetPath(id)));

###Java The Java client library is for REST integration only, but has all of the functionality of the C# version.

Because Java does not support optional parameters in methods, the Client class does not have methods that take a long list of options for each request. Instead, it has a method sendRequest that takes only one parameter -- a request object. This object determines what request will be made and what options will be included.

Creating a HotDocs Embedded session:

Client client = new Client("MySubscriberID", "MySigningKey");
CreateSessionRequest request = new CreateSessionRequest(packageID, myGetPath(packageId));
String sessionId = client.sendRequest(request);

Resuming a HotDocs Embedded session:

Client client = new Client("MySubscriberID", "MySigningKey");
ResumeSessionRequest request = new ResumeSessionRequest(snapshot);
request.setPackageStreamGetter(new FileInputStreamGetter(myGetPath(request.getPackageId())));
String sessionID = client.sendRequest(request);

###PHP The PHP client library is similar to the Java version, but supports only the functionality needed for HotDocs Embedded sessions. Also, the PHP client library currently reads packages from files only, not from streams.

Creating a HotDocs Embedded session:

$client = new Client('MySubscriberID', 'MySigningKey');
$request = new CreateSessionRequest($packageId, myGetPath($packageId));
$sessionId = $client->sendRequest($request);

Resuming a HotDocs Embedded session:

$client = new Client('MySubscriberID', 'MySigningKey');
$request = new ResumeSessionRequest($snapshot);
$request->setPackageFilePath(myGetPath($request->getPackageId()));
$sessionId = $client->sendRequest($request);

###Ruby See the Ruby client library project, maintained by pifleo, for documentation.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.