user1938919
user1938919

Reputation: 53

Using APIServiceSoapClient for DocuSign

Im tring to user the DocuSign api/sdk to send a document for someone to sign. The examples say something like:

//.NET
APIServiceSoapClient apiService = new APIServiceSoapClient();
apiService.ClientCredentials.UserName.UserName = "Your DocuSign UserName here";
apiService.ClientCredentials.UserName.Password = "Your DocuSign Password here";

Which I of course have tried but its not working.

I get the following error: Security requirements are not satisfied because the security header is not present in the incoming message.

Ive tried

var username = "myemail";
var pass = "mypass";
var iteratorKey = "iteratorkey";

APIServiceSoapClient apiService = new APIServiceSoapClient();
apiService.ClientCredentials.UserName.UserName = username; 
//also tried ...UserName = "[" + iteratorKey + "]" + username; 
apiService.ClientCredentials.UserName.Password = pass;

Is this not where all security requirements are met? maybe? Using APIService not DSAPIService if that makes a difference.

Upvotes: 1

Views: 764

Answers (2)

user1938919
user1938919

Reputation: 53

I ended up having to use a different way to pass in the credentials. Which I found somewhere else. Im still not sure how to correctly use the other method I tried though so if anyone knows how to use the other method it would be great just because the code is neater and easier to follow.

string auth = @"<DocuSignCredentials>
                   <Username>email</Username>
                   <Password>pass</Password>
                   <IntegratorKey>key</IntegratorKey>
                </DocuSignCredentials>";

DSAPIServiceSoapClient apiService = new DSAPIServiceSoapClient();            

using (var scope = new System.ServiceModel.OperationContextScope(apiService.InnerChannel))
{
    var httpRequestProperty = new System.ServiceModel.Channels.HttpRequestMessageProperty();
    httpRequestProperty.Headers.Add("X-DocuSign-Authentication", auth);
    System.ServiceModel.OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] = httpRequestProperty;

    EnvelopeStatus envStatus = apiService.CreateAndSendEnvelope(envelope);
    return envStatus.EnvelopeID;
}

Upvotes: 2

Ergin
Ergin

Reputation: 9356

There are two ways to pass member credentials through DocuSign's SOAP API (as opposed to the newer REST API):

  1. SOAP Header via WS-Security UsernameToken
  2. HTTP Header via a custom field “X-DocuSign-Authentication”

The Account Management API only supports the HTTP Header authentication method, while all others can support either method.

Additionally, the DocuSign SOAP API has two API end points: API.asmx and DSAPI.asmx. The API.asmx end point requires the WS-Security UsernameToken in the SOAP header authentication. The DSAPI.asmx and AccountManagement.asmx end points require the HTTP Header authentication method.

Upvotes: 0

Related Questions