Signature Appliance SOAP API C#: User Management and Signing a PDF

This recipe creates a C# Windows application client for the SOAP API. It uses the User Management API to list the appliance’s users. It also demonstrates how to sign a PDF file.

API Recipe source files are available on GitHub.

The SOAP User Management client

Source file: Form1.cs

private void button1_Click(object sender, EventArgs e)
{
    var client = new SPMLSoapClient.SPML();
    
    // build the CoSign Logon Data
    var data = new SPMLSoapClient.CoSignLogonData();
    data.User = txtUsername.Text; 
    data.Password = txtPassword.Text; 
 
    // build a search request
    var searchRequest = new SPMLSoapClient.SearchRequestType();
    searchRequest.CoSignLogonData = data;
    searchRequest.returnData = SPMLSoapClient.ReturnDataType.data;
    searchRequest.maxSelect = 20; // number of users to fetch
    searchRequest.maxSelectSpecified = true;
 
    SPMLSoapClient.SearchResponseType response;
    try
    {
        // make the call
        response = client.search(searchRequest);
        if (response.status != SPMLSoapClient.StatusCodeType.success)
        {
            MessageBox.Show("Error on search: " + response.status + ", " + response.error + 
                ", " + response.errorMessage[0], "Error");
            return;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Error");
        return;
    }
    if (response.pso == null)
    {
        MessageBox.Show("No users!", "OK");
        return;
    }
 
    //populate the text box with the users from the response
    for (int i = 0; i