/// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <exception cref="ApplicationException"></exception>
        public manageProviderDirectoryEntryResponse ManageProviderDirectoryEntry(manageProviderDirectoryEntry request)
        {
            var timestamp = new TimestampType
            {
                created          = DateTime.Now.ToUniversalTime(),
                expires          = DateTime.Now.AddDays(30).ToUniversalTime(),
                expiresSpecified = true
            };

            var directoryEntryRequest = new manageProviderDirectoryEntryRequest(
                product, new SignatureContainerType(), timestamp, user, request);


            LastSoapRequestTimestamp = directoryEntryRequest.timestamp;

            manageProviderDirectoryEntryResponse1 response = null;

            try
            {
                response = providerDirectoryEntryClient.manageProviderDirectoryEntry(directoryEntryRequest);
            }
            catch (Exception ex)
            {
                FaultHelper.ProcessAndThrowFault <ServiceMessagesType>(ex);
            }

            if (response != null && response.manageProviderDirectoryEntryResponse != null)
            {
                return(response.manageProviderDirectoryEntryResponse);
            }

            throw new ApplicationException(Properties.Resources.UnexpectedServiceResponse);
        }
        public void Sample()
        {
            // ------------------------------------------------------------------------------
            // Set up
            // ------------------------------------------------------------------------------

            // Obtain the certificate by serial number
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // The same certificate is used for signing the request.
            // This certificate will be different to TLS cert for some operations.
            X509Certificate2 signingCert = tlsCert;

            // Set up client product information (PCIN)
            // Values below should be provided by Medicare
            ProductType product = new ProductType()
            {
                platform       = "Your system platform (Eg. Windows XP SP3)", // Can be any value
                productName    = "Product Name",                              // Provided by Medicare
                productVersion = "Product Version",                           // Provided by Medicare
                vendor         = new QualifiedId()
                {
                    id        = "Vendor Id",       // Provided by Medicare
                    qualifier = "Vendor Qualifier" // Provided by Medicare
                }
            };

            // Set up user identifier details
            QualifiedId user = new QualifiedId()
            {
                id        = "User Id", // User ID internal to your system
                qualifier = "http://<anything>/id/<anything>/userid/1.0"
                                       // Eg: http://ns.yourcompany.com.au/id/yoursoftware/userid/1.0
            };

            // Set up user identifier details
            QualifiedId hpio = new QualifiedId()
            {
                id        = "HPIO", // HPIO internal to your system
                qualifier = "http://<anything>/id/<anything>/hpio/1.0"
                                    // Eg: http://ns.yourcompany.com.au/id/yoursoftware/userid/1.0
            };

            // ------------------------------------------------------------------------------
            // Call the read interface
            // ------------------------------------------------------------------------------

            // Read the existing values from HI
            ProviderDirectoryOrganisationEntryRecord providerDetails = null;

            // ------------------------------------------------------------------------------
            // Client instantiation and invocation
            // ------------------------------------------------------------------------------

            // Instantiate the client
            var client = new ProviderManageProviderDirectoryEntryClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                signingCert,
                tlsCert);

            // Create the request
            var directoryEntry = new manageProviderDirectoryEntry();

            // Set the items to the published based on the IDs used from the 'read' operation
            var organisationEntryRecord = new ProviderDirectoryOrganisationEntryRecord();

            organisationEntryRecord.externalIdentifier          = (providerDetails != null ? providerDetails.externalIdentifier : 0);
            organisationEntryRecord.externalIdentifierSpecified = (providerDetails != null ? true : false);
            organisationEntryRecord.displayPrivateDetails       = (providerDetails != null ? providerDetails.displayPrivateDetails : false);;
            organisationEntryRecord.priorityNumber = (providerDetails != null ? providerDetails.priorityNumber : 1);
            organisationEntryRecord.display        = true;
            organisationEntryRecord.electronicCommunicationExternalId = (providerDetails != null ? providerDetails.electronicCommunicationExternalId : null);
            organisationEntryRecord.organisationServiceExternalId     = (providerDetails != null ? providerDetails.organisationServiceExternalId : null);

            organisationEntryRecord.nameExternalId    = providerDetails.nameExternalId;
            organisationEntryRecord.addressExternalId = providerDetails.addressExternalId;
            organisationEntryRecord.endpointLocatorServiceExternalId = providerDetails.endpointLocatorServiceExternalId;

            directoryEntry.organisationEntry = new[] { organisationEntryRecord };


            // Submit the request
            try
            {
                manageProviderDirectoryEntryResponse response = client.ManageProviderDirectoryEntry(directoryEntry);
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
        }