internal void InitializeWebService(AFFixture afFixture, ITestOutputHelper output) { if (AFFixture != null) { return; } // Initialize a web service notification contact template AFFixture = afFixture; Service = new TestWebService(); SoapWebServiceHost = new BasicWebServiceHost(Service, typeof(IWebService)); try { SoapWebServiceHost.Start(ServiceName, ServiceUri); } catch (AddressAccessDeniedException) { SoapWebServiceHost = null; Service = null; output.WriteLine($"Warning: The Web Service endpoint [{ServiceUri}] could not be opened."); output.WriteLine("There are two ways how to fix the problem:"); output.WriteLine("1. Use netsh add urlacl to add the current user for the service prefix http://+:9001/notificationtest"); output.WriteLine("2. Run tests as administrator."); return; } var webServiceSoap = new AFNotificationContactTemplate(afFixture.PISystem, $"{TestPrefix}_{TestInfix}_WebServiceSoap*") { DeliveryChannelPlugIn = afFixture.PISystem.DeliveryChannelPlugIns[WebServicePlugInName], ConfigString = $"Style=SOAP;WebServiceName={ServiceName};WebServiceMethod={nameof(IWebService.Test)};WebServiceUrl={ServiceUri}", }; _soapWebServiceId = webServiceSoap.ID; _notificationContactTemplateIds.Add(webServiceSoap.ID); AFFixture.PISystem.CheckIn(); output.WriteLine($"Created web service notification contact template [{webServiceSoap.Name}]."); }
internal void InitializeWebService(AFFixture afFixture, ITestOutputHelper output) { if (AFFixture != null) { return; } // Initialize a web service notification contact template AFFixture = afFixture; Service = new TestWebService(); SoapWebServiceHost = new BasicWebServiceHost(Service, typeof(IWebService)) { UseExactMatchForLocalhost = false, }; try { SoapWebServiceHost.Start(ServiceName, ServiceUri); } catch (AddressAccessDeniedException ex) { throw new Exception( $"Endpoint [{ServiceUri}] could not be opened. There are 3 possible solutions: " + "1) If notifications service and the tests are run on the same machine, set UseExactMatchForLocalhost=true; " + "2) Use netsh add urlacl to add the current user for the service prefix http://+:9001/notificationtest; " + "3) Run tests as administrator.", ex); } var webServiceSoap = new AFNotificationContactTemplate(afFixture.PISystem, $"{TestPrefix}_{TestInfix}_WebServiceSoap*") { DeliveryChannelPlugIn = afFixture.PISystem.DeliveryChannelPlugIns[WebServicePlugInName], ConfigString = $"Style=SOAP;WebServiceName={ServiceName};WebServiceMethod={nameof(IWebService.Test)};WebServiceUrl={ServiceUri}", }; _soapWebServiceId = webServiceSoap.ID; _notificationContactTemplatIds.Add(webServiceSoap.ID); AFFixture.PISystem.CheckIn(); output.WriteLine($"Created web service notification contact template [{webServiceSoap.Name}]."); }