/// <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 searchForProviderOrganisationResponse ProviderOrganisationSearch(searchForProviderOrganisation request) { var envelope = new searchForProviderOrganisationRequest() { searchForProviderOrganisation = 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; searchForProviderOrganisationResponse1 response1 = null; try { response1 = providerSearchForProviderOrganisationClient.searchForProviderOrganisation(envelope); providerSearchForProviderOrganisationClient.searchForProviderOrganisation(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.searchForProviderOrganisationResponse != null) { return(response1.searchForProviderOrganisationResponse); } 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 ProviderSearchForProviderOrganisationClient( new Uri("https://HIServiceEndpoint"), product, user, hpio, signingCert, tlsCert); // Create the search request var request = new searchForProviderOrganisation() { hpioNumber = HIQualifiers.HPIOQualifier + "HPIO TO SEARCH" }; try { // Invokes the batch search var response = client.ProviderOrganisationSearch(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; } }