/// <summary> /// Perform the service call. /// </summary> /// <param name="request">The search criteria in a searchHIProviderDirectoryForIndividual object.</param> /// <returns>The search results in a searchHIProviderDirectoryForIndividualResponse object.</returns> public searchForProviderIndividualResponse ProviderIndividualSearch(searchForProviderIndividual request) { var envelope = new searchForProviderIndividualRequest() { searchForProviderIndividual = request, product = product, user = user, hpio = hpio, signature = new SignatureContainerType() }; envelope.timestamp = new TimestampType() { created = DateTime.Now, expires = DateTime.Now.AddDays(30), expiresSpecified = true }; // Set LastSoapRequestTimestamp LastSoapRequestTimestamp = envelope.timestamp; searchForProviderIndividualResponse1 response1 = null; try { response1 = providerSearchForProviderIndividualClient.searchForProviderIndividual(envelope); providerSearchForProviderIndividualClient.searchForProviderIndividual(envelope); } catch (Exception ex) { // Catch generic FaultException and call helper to throw a more specific fault // (FaultException<ServiceMessagesType> FaultHelper.ProcessAndThrowFault <ServiceMessagesType>(ex); } if (response1 != null && response1.searchForProviderIndividualResponse != null) { return(response1.searchForProviderIndividualResponse); } else { 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 }; // ------------------------------------------------------------------------------ // Client instantiation and invocation // ------------------------------------------------------------------------------ // Instantiate the client var client = new ProviderSearchForProviderIndividualClient( new Uri("https://HIServiceEndpoint"), product, user, hpio, signingCert, tlsCert); // Create the search request var request = new searchForProviderIndividual() { hpiiNumber = HIQualifiers.HPIIQualifier + "HPII TO TO SEARCH", familyName = "Family name of provider" }; try { // Invokes the batch search var response = client.ProviderIndividualSearch(request); } catch (Exception ex) { // If an error is encountered, client.LastSoapResponse often provides a more // detailed description of the error. string soapResponse = client.SoapMessages.SoapResponse; } }