[BACK-GOV-03] SOAP Network Server Implementation and XML Request/Response Modeling
Backend: Architecture
NoteTask Brief
- Repository / Component:
gov_identity_soap_mock. - Language: Go (1.27+).
- Task Type: Backend (Stack Components).
- Status: Ready for Implementation
Task Description
It is necessary to spin up an HTTP server listening on port :8000 and design strongly-typed structures (data types) to parse incoming and construct outgoing enterprise-level messages in the SOAP/XML format.
Step-by-Step Instructions
- Modeling the Incoming SOAP Envelope: Based on the standard namespace
http://xmlsoap.org, define theSoapEnvelopeRequeststructure and its nested Body object for thefetch_secure_employee_datamethod, which acceptsemailandmaster_tokenfields. - Modeling the Outgoing Response: Design the
SoapEnvelopeResponseXML structure supporting bothsoapenvandgovnamespace attributes. The employee profile fields (inn,passport,snils,gov_status) must include theomitemptytag so they are omitted from the XML serialization in case of errors. - HTTP Server Initialization: In the
main()function, configure the standardhttp.HandleFuncrouter mapping to the root path/and start listening on the port usinghttp.ListenAndServe(":8000", nil). - Response Transmission Helper: Implement a helper function
sendSoapResponsethat handles marshaling the response structure with indentation viaxml.MarshalIndent, sets theContent-Type: text/xml; charset=utf-8header, and explicitly writes thexml.Headerto the HTTP response body.