Produce a certified-mail label¶
SimpleCertifiedMailServiceProxy wraps the third-party SimpleCertifiedMail ADS SOAP service (ADSAPISoapClient) to size, request, and optionally save a certified-mail label image, resolving credentials from configuration unless the caller supplies them and logging any failed label response before raising it.
| Field | Value |
|---|---|
| Operation ID | OP-WP-08 |
| Trigger | SubpoenaLabelService and DocumentDeferredService in SAIF.Services, through the constructor-injected ISimpleCertifiedMailServiceProxy |
| Inputs | CertifiedLabelData, number of pages, an optional IsProductionMode flag |
| Outputs | A Base64 GIF label image, a saved .gif file, or a thrown exception |
| Primary components | SimpleCertifiedMailServiceProxy.GetDefaultLabelData, GetLabelOnly, SaveLabelAsGif, GetCertifiedLabel, GetModeOption |
| Entry point | Services/SAIF.Services.Web.Proxies/SimpleCertifiedMailServiceProxy.cs |
Steps¶
- Construct
SimpleCertifiedMailServiceProxy(IEnvironmentService, ILogService): - Guard both injected services (WP-BR-001).
- Create an HTTPS
BasicHttpBinding(Transport)client withint.MaxValuequotas. - Read the endpoint from
GetConfigSetting("SimpleCertifiedMailService.Url")(WP-BR-014). GetDefaultLabelData(numberOfPages): (WP-BR-015)- Start with
EnvelopeSize10,GIFformat, andNotifySender = false. - If pages > 10, use
Small. If pages > 19, useLarge.- If pages > 76: throw
InvalidNumberOfPagesException.
- If pages > 76: throw
- Set
GroupName = "ADMINISTRATION". GetLabelOnly(data): call step 5'sGetCertifiedLabel(data)and discard the returned image (WP-BR-016); its only effect is the remote request and any exception.SaveLabelAsGif(data, fileName):- Call
GetCertifiedLabel(data). If the result is null, return without writing anything. - Otherwise, Base64-decode the label into a
MemoryStream, create aBitmap, and save it asfileName + ".gif"in GIF format. - The stream and bitmap are disposed in a
finallyblock. GetCertifiedLabel(data)(private):- Build a
CertifiedLabelRequest. - Truncate
FromAddress1,FromAddress2, andToNameto 46 characters (WP-BR-017). - Default
GroupNameto"ADMINISTRATION". - Default
UserName,Password,ClientCode, andPartnerKeyto theSimpleCertifiedMailService.*configuration settings when the caller leaves them null (WP-BR-014). - Set
ModeviaGetModeOption(step 6). - Fix
DateAdvance = 0,UseSL250 = false, andSortType = None. - Call wire
getCertifiedLabel(request).- If
StatusCode != 1: create aSimpleCertifiedException("SimpleCertifiedMailServiceProxy Error: {StatusMessage}"), log it viaILogService.LogException("SimpleCertifiedMailService", "GetCertifiedLabel", "", ex), and throw it (WP-BR-018).
- If
- Otherwise, return
LabelImage(Base64). GetModeOption(isProductionMode): (WP-BR-019)- An explicit
truereturnsproduction; an explicitfalsereturnspreview. - When
isProductionModeis null, the mode isproductionifIEnvironmentService.IsProductionis true, andpreviewotherwise.
Process flow¶
The following diagram visualizes the certified-label request, including its failure path.
flowchart TD
Start([GetLabelOnly / SaveLabelAsGif invoked]) --> Build["Build CertifiedLabelRequest<br>(truncate fields, default credentials)"]
Build --> Mode["Resolve Mode via GetModeOption"]
Mode --> Wire["Call wire getCertifiedLabel(request)"]
Wire --> Check{"StatusCode == 1?"}
Check -->|No| Log["Log via ILogService.LogException"] --> Throw([Throw SimpleCertifiedException])
Check -->|Yes| Ret(["Return LabelImage, Base64"])
Failure and edge-case behavior¶
- Requesting a label for more than 76 pages throws
InvalidNumberOfPagesExceptioninGetDefaultLabelData, before any wire call. - A missing/invalid injected
IEnvironmentServiceorILogServiceat construction throws an argument exception. - A non-
1StatusCodein the wire response is always logged and raised asSimpleCertifiedException. SaveLabelAsGifreturns silently, writing nothing, whenGetCertifiedLabelreturns a null label.- Callers can bypass configuration entirely by supplying
UserName/Password/ClientCode/PartnerKeydirectly onCertifiedLabelData—DocumentDeferredService.cslines 112–114 do this — in which case the configuration values are not read for that request.
Related documentation¶
Sources¶
Services/SAIF.Services.Web.Proxies/SimpleCertifiedMailServiceProxy.csServices/SAIF.Services.Web.Proxies/ISimpleCertifiedMailServiceProxy.cs