/// <summary> /// Deliver a Sealed Message to a Receiver or Intermediary and receive an immediate response in return. /// </summary> /// <param name="message">The encrypted payload to deliver.</param> /// <param name="endpointUrl">The endpoint of the destination endpoint service.</param> /// <returns>Acknowledgement on the deliver operation.</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 (simdClient is Nehta.SMD2010.SIMD.SealedImmediateMessageDeliveryClient) { Nehta.SMD2010.SIMD.SealedImmediateMessageDeliveryClient client = (Nehta.SMD2010.SIMD.SealedImmediateMessageDeliveryClient)simdClient; client.Endpoint.Address = new EndpointAddress(endpointUrl); } deliverRequest request = new deliverRequest(); request.deliver = new deliver(); request.deliver.message = message; deliverResponse1 response = simdClient.deliver(request); if (response != null && response.deliverResponse != null) { return(response.deliverResponse); } else { throw new ApplicationException(Properties.Resources.UnexpectedServiceResponse); } }
/// <summary> /// Initializes an instance of the SealedImmediateMessageDeliveryClient. /// </summary> /// <param name="configurationName">Endpoint configuration name for the SIMD endpoint.</param> /// <param name="tlsCert">The client certificate to establish the TLS connection with.</param> private void InitializeClient(string configurationName, X509Certificate2 tlsCert) { this.simdMessages = new SoapInspector.SoapMessages(); Nehta.SMD2010.SIMD.SealedImmediateMessageDeliveryClient client = null; if (!string.IsNullOrEmpty(configurationName)) { client = new Nehta.SMD2010.SIMD.SealedImmediateMessageDeliveryClient(configurationName); } else { EndpointAddress address = new EndpointAddress("http://ns.electronichealth.net.au"); CustomBinding tlsBinding = GetBinding(); client = new Nehta.SMD2010.SIMD.SealedImmediateMessageDeliveryClient(tlsBinding, address); } if (client != null) { SoapInspector.InspectEndpoint(client.Endpoint, simdMessages); client.ClientCredentials.ClientCertificate.Certificate = tlsCert; simdClient = client; } }