---
title: Consumption
summary: How a consuming application references, constructs, calls, and disposes the proxy.
status: draft
owner: SAIF.Core documentation
last_reviewed: 2026-09-24
---

# Consumption

A consumer constructs `SimpleCertifiedMailServiceProxy` directly; it resolves its own endpoint from configuration and its own credential fallbacks. `SAIF.Services.Web.Proxies`, the library that carries this proxy, is itself consumed as a library within this run — see [`saif-services-web-proxies`](../../libraries/saif-services-web-proxies/overview.md). The only in-repository consumer is `SAIF.Services.Legal.Subpoenas.SubpoenaLabelService`.

## Reference style

| Field | Value |
| --- | --- |
| Mechanism | Service Reference (svcutil) |
| Declared in | `Services/SAIF.Services.Web.Proxies/SAIF.Services.Web.Proxies.csproj` |
| Generated artifacts | `Services/SAIF.Services.Web.Proxies/Service References/SimpleCertifiedMail/` |
| Target framework | .NET Framework 4.6.2 |
| Regeneration command | Visual Studio "Update Service Reference" |

## Construction

```csharp
var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
{
    MaxReceivedMessageSize = int.MaxValue,
    MaxBufferSize = int.MaxValue,
    ReaderQuotas = new XmlDictionaryReaderQuotas { MaxArrayLength = int.MaxValue },
    Security =
    {
        Transport = { ClientCredentialType = HttpClientCredentialType.None },
        Message = { ClientCredentialType = BasicHttpMessageCredentialType.Certificate }
    }
};
var serviceUrl = _environmentService.GetConfigSetting("SimpleCertifiedMailService.Url");
_webService = new ADSAPISoapClient(binding, new EndpointAddress(serviceUrl));
```

| Step | Requirement |
| --- | --- |
| Endpoint address | Environment setting `SimpleCertifiedMailService.Url`, read through `IEnvironmentService` |
| Binding | Constructed in code (`BasicHttpBinding(Transport)` with unbounded message size, buffer size, and array length) |
| Credentials | Transport: none. Application-level: `UserName`/`Password`/`ClientCode`/`PartnerKey` in the SOAP body, falling back to environment settings when not supplied by the caller |
| Initialization | Single-constructor — the wrapper resolves configuration and constructs the generated client together |

## Endpoint configuration

| Setting | Value | Source | Changeable without a rebuild |
| --- | --- | --- | --- |
| Endpoint address | Unresolved** — `SimpleCertifiedMailService.Url` | `SimpleCertifiedMailServiceProxy.cs:42` | Yes — read from configuration, but the key is not defined anywhere in this repository's configuration |
| Binding configuration | Constructed in code | `SimpleCertifiedMailServiceProxy.cs:31-41` | No — changing binding settings requires a rebuild |
| Security mode | `Transport` (HTTPS) | `SimpleCertifiedMailServiceProxy.cs:31` | No |

The generated `<client><endpoint name="ADSAPISoap">` in `app.config` (`address="https://api.simplecertifiedmail.com/v3.2/ADS.asmx"`) is present but bypassed — the wrapper never uses the name-based constructor.

## Resilience

| Concern | Finding | Configurable by consumer | Source | Tech debt |
| --- | --- | --- | --- | --- |
| Timeout | None configured — binding defaults apply | No | `SimpleCertifiedMailServiceProxy.cs:31-41` | Yes |
| Retry | None configured | No | — | Yes |
| Circuit breaking | None configured | No | — | Yes |
| Thread safety | Not determined from source | — | — | No |
| Cancellation | Not supported — no cancellation on the call site | — | `SimpleCertifiedMailServiceProxy.cs:131` | Yes |
| Message size limits | `MaxReceivedMessageSize`, `MaxBufferSize`, `MaxArrayLength` all `int.MaxValue` — effectively unbounded | No | `SimpleCertifiedMailServiceProxy.cs:33-35` | Yes |

There is no client-side retry, so a transient failure fails the single attempt outright — the calling `SubpoenaLabelService` methods catch only `SimpleCertifiedException` (the in-band failure type), so a `CommunicationException` or `TimeoutException` propagates uncaught in most call paths. See [Tech debt](tech-debt.md).

## Disposal

| Aspect | Finding |
| --- | --- |
| Disposal performed | `Close()` only |
| Faulted channel handled | No — a faulted channel throws from `Close()` and masks the original failure* |
| Wrapper responsibility | `SimpleCertifiedMailServiceProxy` disposes the generated client |
| Source | `Services/SAIF.Services.Web.Proxies/SimpleCertifiedMailServiceProxy.cs:159-173` |

```csharp
public void Dispose()
{
    _webService.Close();
}
```

## Error handling for consumers

| Failure | Surfaces as | Consumer action |
| --- | --- | --- |
| Service unreachable | `EndpointNotFoundException`* | Not handled by the wrapper; `SubpoenaLabelService.GenerateRecipientLabels`/`GenerateOpposingCounselLabel` catch only `SimpleCertifiedException`, so this propagates |
| SOAP fault returned | `FaultException`* | Same as above — propagates |
| Timeout exceeded | `TimeoutException`* | Same as above — propagates |
| Response larger than the message size limit | Not applicable — limits are effectively unbounded | — |
| In-band failure (`StatusCode != 1`) | `SimpleCertifiedException` | Caught by `SubpoenaLabelService`, which emails support and, in `GenerateRecipientLabels`, skips the affected recipient |

## Usage examples

```csharp
// SubpoenaLabelService.GenerateRecipientLabels — one label per recipient
try
{
    _simpleCertifiedMailServiceProxy.SaveLabelAsGif(labelData, fileName);
}
catch (Proxy.SimpleCertifiedException)
{
    SendEmailForInvalidAddress(subpoena, recipient);
}
```

| Scenario | Operations used | Notes |
| --- | --- | --- |
| Subpoena recipient labeling | `getCertifiedLabel` | One label per recipient; an in-band failure is emailed to support and the recipient is skipped, but the loop continues |
| Opposing-counsel labeling | `getCertifiedLabel` | An in-band failure is emailed to support, but the computed `LabelSize` is still returned, and the downstream `OpposingCounselService` may reference a `.gif` file that was never written |

## Lifecycle guidance

| Question | Answer |
| --- | --- |
| Construct once or per call | Not determined from source |
| Disposable | Yes (`IDisposable`) |
| Safe to share across threads | Not determined from source |

## Related documentation
- [Client index](index.md)
- [Overview](overview.md)
- [Architecture](architecture.md)
- [Contract](contract.md)
- [Operation map](operation-map.md)
- [Client reference](reference.md)
- [Dependencies](dependencies.md)
- [Business rules](business-rules.md)
- [Tech debt](tech-debt.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- `Services/SAIF.Services.Web.Proxies/SimpleCertifiedMailServiceProxy.cs`
- `Services/SAIF.Services.Web.Proxies/app.config`
- `Services/SAIF.Services/Legal/Subpoenas/SubpoenaLabelService.cs`
- `Services/SAIF.Services/Legal/Subpoenas/OpposingCounselService.cs`
