/// <summary>
        /// Create an instance of CommonSealedMessageType.
        /// </summary>
        /// <param name="m">The SealedMessageType instance to copy.</param>
        public CommonSealedMessageType(Nehta.SMD2010.SMD.SealedMessageType m)
        {
            ServiceCategory      = m.metadata.serviceCategory;
            InvocationId         = m.metadata.invocationId;
            ReceiverOrganisation = m.metadata.receiverOrganisation;
            SenderOrganisation   = m.metadata.senderOrganisation;
            EncryptedPayload     = (object)m.encryptedPayload;

            ValidateCommonSealedMessageType();
        }
        public void Sample()
        {
            // This example shows a Transport Response Delivery (TRD) message creation after a message
            // is received via Sealed Message Delivery (SMD). A static helper method is provided on
            // the client to help generate a TransportResponseType instance from a SealedMessageType
            // instance received via SMD, SIMD, or SMR.

            // TLS certificate used to authenticate the client to the TRD service during TLS connection.
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate("TlsCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Certificate used to decrypt a received SealedMessageType payload.
            X509Certificate2 payloadDecryptionCert = X509CertificateUtil.GetCertificate("PayloadDecryptionCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Set up client.
            TransportResponseDeliveryClient trdClient = new TransportResponseDeliveryClient(tlsCert);

            // The SealedMessageType instance to generate a Transport Response for.
            // Typically, this would be available after an SMD, SIMD or SMR service invocation.
            Nehta.SMD2010.SMD.SealedMessageType sealedMessage = new Nehta.SMD2010.SMD.SealedMessageType();

            // Generate the Transport Response for the Sealed Message.
            TransportResponseType transportResponse = TransportResponseDeliveryClient.GetTransportResponse(
                new CommonSealedMessageType(sealedMessage),
                HIQualifiers.HPIOQualifier + "16 digit HPIO of sender organisation",
                ResponseClassType.Success,
                "DeliveryResponseCode",
                "DeliveryResponseMessage",
                DateTime.Now.ToUniversalTime(),
                new UniqueId().ToString(),
                true,
                null,
                payloadDecryptionCert
                );

            // Add the generated Transport Response to a list.
            List <TransportResponseType> transportResponses = new List <TransportResponseType>();

            transportResponses.Add(transportResponse);

            // Invoke the Deliver operation on the client, passing in the list of Transport Responses.
            deliverResponse response = trdClient.Deliver(transportResponses, new Uri("https://TRDServiceEndpoint"));
        }