public void Sample() { // Payload XmlDocument payload = new XmlDocument(); payload.LoadXml("<data>Sample data to deliver.</data>"); // TLS certificate used to authenticate the client to the SMD service during TLS connection. X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate("TlsCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true); // Certificate used to sign the payload. X509Certificate2 signingCert = X509CertificateUtil.GetCertificate("SigningCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true); // Certificate used to encrypt the payload. X509Certificate2 payloadEncryptionCert = X509CertificateUtil.GetCertificate("EncryptionCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true); // Instantiate the client. SealedMessageDeliveryClient client = new SealedMessageDeliveryClient(tlsCert); // Set up metadata MessageMetadataType metadata = new MessageMetadataType(); metadata.creationTime = DateTime.Now.ToUniversalTime(); metadata.expiryTime = DateTime.Now.AddDays(30).ToUniversalTime(); metadata.expiryTimeSpecified = true; metadata.invocationId = new UniqueId().ToString(); metadata.receiverIndividual = HIQualifiers.HPIIQualifier + "16 digit receiver HPII"; metadata.receiverOrganisation = HIQualifiers.HPIOQualifier + "16 digit receiver organisation HPIO"; metadata.senderIndividual = HIQualifiers.HPIIQualifier + "16 digit sender HPII"; metadata.senderOrganisation = HIQualifiers.HPIOQualifier + "16 digit sender organisation HPIO"; metadata.serviceCategory = "ServiceCategory"; metadata.serviceInterface = ServiceInterfaces.SmdServiceInterface; // Set up route record. Route records are used to indicate where transport responses // are to be sent to. metadata.routeRecord = new RouteRecordEntryType[1]; metadata.routeRecord[0] = new RouteRecordEntryType(); metadata.routeRecord[0].sendIntermediateResponses = false; metadata.routeRecord[0].interaction = new InteractionType(); metadata.routeRecord[0].interaction.target = HIQualifiers.HPIOQualifier + "16 digit HPIO of the transport response target"; metadata.routeRecord[0].interaction.serviceCategory = "ServiceCategory"; metadata.routeRecord[0].interaction.serviceEndpoint = "https://TransportResponseDeliveryEndpoint"; metadata.routeRecord[0].interaction.serviceInterface = ServiceInterfaces.TrdServiceInterface; metadata.routeRecord[0].interaction.serviceProvider = HIQualifiers.HPIOQualifier + "16 digit HPIO of the TRD service provider"; // Obtain a SealedMessageType instance. SealedMessageType sealedMessage = SealedMessageDeliveryClient.GetSealedMessage(payload, metadata, signingCert, payloadEncryptionCert); // Invoke the Deliver operation on the client. deliverResponse response = client.Deliver(sealedMessage, new Uri("https://SMDServiceEndpoint")); }
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")); }