Modified code to work with the new SearchServiceEndpoint class.