/// <summary> /// Deliver a Sealed Message to a Receiver or Intermediary. /// </summary> /// <param name="message">The message to deliver.</param> /// <param name="endpointUrl">The endpoint of the SMD service.</param> /// <returns>A value indicating if the operation is successful.</returns> public deliverResponse Deliver(SealedMessageType message, Uri endpointUrl) { Validation.ValidateArgumentRequired("message", message); Validation.ValidateArgumentRequired("endpointUrl", endpointUrl); // Validate metadata ValidateMetadata(message.metadata); // Validate encrypted payload Validation.ValidateArgumentRequired("message.encryptedPayload", message.encryptedPayload); if (smdClient is Nehta.SMD2010.SMD.SealedMessageDeliveryClient) { Nehta.SMD2010.SMD.SealedMessageDeliveryClient client = (Nehta.SMD2010.SMD.SealedMessageDeliveryClient)smdClient; client.Endpoint.Address = new EndpointAddress(endpointUrl); } deliverRequest request = new deliverRequest(); request.deliver = new deliver(); request.deliver.message = message; deliverResponse1 response = smdClient.deliver(request); if (response != null && response.deliverResponse != null) { return(response.deliverResponse); } else { throw new ApplicationException(Properties.Resources.UnexpectedServiceResponse); } }
/// <summary> /// Initializes an instance of the SealedMessageDeliveryClient. /// </summary> /// <param name="configurationName">Endpoint configuration name for the SMD endpoint.</param> /// <param name="tlsCert">The client certificate to be used to establish the TLS connection.</param> private void InitializeClient(string configurationName, X509Certificate2 tlsCert) { this.smdMessages = new SoapInspector.SoapMessages(); Nehta.SMD2010.SMD.SealedMessageDeliveryClient client = null; if (!string.IsNullOrEmpty(configurationName)) { client = new Nehta.SMD2010.SMD.SealedMessageDeliveryClient(configurationName); } else { EndpointAddress address = new EndpointAddress("https://ns.electronichealth.net.au"); CustomBinding tlsBinding = GetBinding(); client = new Nehta.SMD2010.SMD.SealedMessageDeliveryClient(tlsBinding, address); } if (client != null) { SoapInspector.InspectEndpoint(client.Endpoint, smdMessages); client.ClientCredentials.ClientCertificate.Certificate = tlsCert; smdClient = client; } }