---
title: Architecture
summary: How the proxy is constructed, configured, invoked, and disposed.
status: draft
owner: SAIF.Core documentation
last_reviewed: 2026-09-24
---

# Architecture

Three authored adapter classes wrap the generated `clsCAServices` proxy; each adapter receives the proxy through its constructor rather than constructing it directly, and no repository source constructs an adapter outside tests.

## Proxy mechanism

| Aspect | Finding |
| --- | --- |
| Mechanism | Web Reference (wsdl.exe) |
| Proxy type | `SAIF.Services.CleanAddressSvc.clsCAServices` |
| Base type | `System.Web.Services.Protocols.SoapHttpClientProtocol` |
| Contract type | Not applicable — the proxy class is the surface |
| Constructed in | `Tests/SAIF.Services.Tests/Utilities/WhenCleansingAddress.cs:27,40` and `WhenSearchingAddress.cs:15` (tests only; no production call site constructs it) |
| Binding configured in | Not applicable — ASMX transport defaults |
| Address supplied by | Generated settings (`SAIF.Services.Properties.Settings.Default.SAIF_Services_CleanAddressSvc_clsCAServices`) |

## Construction path

The following diagram visualizes how a call reaches the remote service.

```mermaid
flowchart TD
    CALLER["CleanAddressService /<br>AddressSearchService /<br>CleanAddressBatchService"] --> WRAP["CleanAddressServiceBase<br>hand-written wrapper"]
    WRAP --> ADDR["Url from generated settings<br>SAIF_Services_CleanAddressSvc_clsCAServices"]
    ADDR --> PROXY["clsCAServices<br>generated proxy"]
    PROXY --> REMOTE["Remote service<br>clsCAServices (ASMX)"]
    WRAP --> DISPOSE["Dispose() on the base class"]
```

## Hand-written wrapper

| Field | Value |
| --- | --- |
| **Type** | `SAIF.Services.Utilities.CleanAddress.CleanAddressServiceBase` |
| **Source** | `Services/SAIF.Services/Utilities/CleanAddress/CleanAddressServiceBase.cs` |
| **Visibility** | `public` (abstract base of `CleanAddressService`, `AddressSearchService`, `CleanAddressBatchService`) |
| **Implements** | `IDisposable` |
| **Responsibility** | Accepts the injected `clsCAServices` instance, guards it with `Enforce.ArgumentNotNull`, sets `AllowAutoRedirect` and `UseDefaultCredentials`, and disposes it |
| **Proxy lifetime** | Per wrapper instance — the constructor receives one proxy instance and holds it for the wrapper's lifetime |

| Configuration applied | Value | Source |
| --- | --- | --- |
| Redirects | `AllowAutoRedirect = true` | `CleanAddressServiceBase.cs:20` |
| Credentials | `UseDefaultCredentials = true` | `CleanAddressServiceBase.cs:21` |
| Timeout | Not set anywhere in repository source — the `WebClientProtocol` default of 100,000 ms applies* | — |

## Endpoint resolution

| Environment | Address | Resolved from | Changeable without a rebuild |
| --- | --- | --- | --- |
| All (no per-environment variant found) | `http://correctaddress/wsCorrectAddress/clsCAServices.asmx` | `Services/SAIF.Services/Properties/Settings.Designer.cs:29` (compiled default) | No — a class-library `app.config` is not loaded by the consuming host, so the effective value inside this repository is the compiled default; overriding it requires a host outside this repository to define `applicationSettings/SAIF.Services.Properties.Settings/SAIF_Services_CleanAddressSvc_clsCAServices`* |

## Lifetime and disposal

| Aspect | Finding |
| --- | --- |
| Proxy lifetime | Per wrapper instance |
| Disposal | `Dispose()` on `CleanAddressServiceBase`, which disposes the injected proxy (`CleanAddressServiceBase.cs:26-39`) |
| Faulted-channel handling | Not applicable — ASMX proxies do not have WCF channel faults; a `SoapException`/`WebException` propagates from the call itself |
| Thread safety | Not determined from source |

## Integration points

| System | Type | Purpose |
| --- | --- | --- |
| `clsCAServices` | ASMX web service | Address cleansing, text normalization, ZIP lookup, and batch processing, delegated to a vendor engine* |

## Related documentation
- [Client index](index.md)
- [Overview](overview.md)
- [Contract](contract.md)
- [Operation map](operation-map.md)
- [Client reference](reference.md)
- [Consumption](consumption.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.

## Sources
- `Services/SAIF.Services/Utilities/CleanAddress/CleanAddressServiceBase.cs`
- `Services/SAIF.Services/Properties/Settings.Designer.cs`
- `Services/SAIF.Services/app.config`
- `Tests/SAIF.Services.Tests/Utilities/WhenCleansingAddress.cs`
- `Tests/SAIF.Services.Tests/Utilities/WhenSearchingAddress.cs`
