Skip to content

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

  1. Construct SimpleCertifiedMailServiceProxy(IEnvironmentService, ILogService):
  2. Guard both injected services (WP-BR-001).
  3. Create an HTTPS BasicHttpBinding(Transport) client with int.MaxValue quotas.
  4. Read the endpoint from GetConfigSetting("SimpleCertifiedMailService.Url") (WP-BR-014).
  5. GetDefaultLabelData(numberOfPages): (WP-BR-015)
  6. Start with EnvelopeSize10, GIF format, and NotifySender = false.
  7. If pages > 10, use Small. If pages > 19, use Large.
    • If pages > 76: throw InvalidNumberOfPagesException.
  8. Set GroupName = "ADMINISTRATION".
  9. GetLabelOnly(data): call step 5's GetCertifiedLabel(data) and discard the returned image (WP-BR-016); its only effect is the remote request and any exception.
  10. SaveLabelAsGif(data, fileName):
  11. Call GetCertifiedLabel(data). If the result is null, return without writing anything.
  12. Otherwise, Base64-decode the label into a MemoryStream, create a Bitmap, and save it as fileName + ".gif" in GIF format.
  13. The stream and bitmap are disposed in a finally block.
  14. GetCertifiedLabel(data) (private):
  15. Build a CertifiedLabelRequest.
  16. Truncate FromAddress1, FromAddress2, and ToName to 46 characters (WP-BR-017).
  17. Default GroupName to "ADMINISTRATION".
  18. Default UserName, Password, ClientCode, and PartnerKey to the SimpleCertifiedMailService.* configuration settings when the caller leaves them null (WP-BR-014).
  19. Set Mode via GetModeOption (step 6).
  20. Fix DateAdvance = 0, UseSL250 = false, and SortType = None.
  21. Call wire getCertifiedLabel(request).
    • If StatusCode != 1: create a SimpleCertifiedException("SimpleCertifiedMailServiceProxy Error: {StatusMessage}"), log it via ILogService.LogException("SimpleCertifiedMailService", "GetCertifiedLabel", "", ex), and throw it (WP-BR-018).
  22. Otherwise, return LabelImage (Base64).
  23. GetModeOption(isProductionMode): (WP-BR-019)
  24. An explicit true returns production; an explicit false returns preview.
  25. When isProductionMode is null, the mode is production if IEnvironmentService.IsProduction is true, and preview otherwise.

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 InvalidNumberOfPagesException in GetDefaultLabelData, before any wire call.
  • A missing/invalid injected IEnvironmentService or ILogService at construction throws an argument exception.
  • A non-1 StatusCode in the wire response is always logged and raised as SimpleCertifiedException.
  • SaveLabelAsGif returns silently, writing nothing, when GetCertifiedLabel returns a null label.
  • Callers can bypass configuration entirely by supplying UserName/Password/ClientCode/PartnerKey directly on CertifiedLabelData — DocumentDeferredService.cs lines 112–114 do this — in which case the configuration values are not read for that request.

Sources

  • Services/SAIF.Services.Web.Proxies/SimpleCertifiedMailServiceProxy.cs
  • Services/SAIF.Services.Web.Proxies/ISimpleCertifiedMailServiceProxy.cs