From d7ca5cad32a4d89b433087819f9badc246ae3f8f Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Thu, 15 Aug 2019 20:46:53 +0200 Subject: [PATCH] Updated WireMock as a standalone process (markdown) --- WireMock-as-a-standalone-process.md | 37 ++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/WireMock-as-a-standalone-process.md b/WireMock-as-a-standalone-process.md index 1c8240c..ba52986 100644 --- a/WireMock-as-a-standalone-process.md +++ b/WireMock-as-a-standalone-process.md @@ -1,13 +1,6 @@ # WireMock as a standalone process This is quite straight forward to launch a mock server within a console application. -## Workaround for Microsoft.Owin.Host.HttpListener exception -Note that when using WireMock in a **NET 4.5x**, **NET 4.6.x** project, you can get this exception when running your console application: - -> Unhandled Exception: System.Exception: Service start failed with error: The server factory could not be located for > the given input: Microsoft.Owin.Host.HttpListener ---> System.MissingMemberException: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener - -The solution is to add the `Microsoft.Owin.Host.HttpListener` (version **4.0.0**) NuGet package to your hosting console application. - ### Option 1 : using the WireMock.Net.StandAlone library. (https://www.nuget.org/packages/WireMock.Net.StandAlone/) ```c# @@ -23,6 +16,27 @@ class Program } ``` +The following commandline arguments can be defined: + +| command | value type | default | details | +| - | - | - | - | +| `--Port` | integer | | [wiki-port](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#port) +| `--Urls` | string| | [wiki-urls](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#urls) +| `--StartAdminInterface` | boolean | true | Defines whether to start admin interface. | +| `--AllowPartialMapping` | boolean | false | [wiki-allowpartialmapping](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#allowpartialmapping) | +| `--ReadStaticMappings` | boolean | false | Defines if the static mappings should be read at startup. | +| `--AdminUsername` | string | | [wiki-adminusername](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#adminusername) | +| `--AdminPassword` | string | | [wiki-adminpassword](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#adminpassword) | +| `--MaxRequestLogCount` | integer | | [wiki-maxrequestlogcount](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#maxrequestlogcount) +| `--RequestLogExpirationDuration` | integer | | [wiki-requestlogexpirationduration](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#requestlogexpirationduration) | +| `--WireMockConsoleLogger` | string | [WireMockNullLogger](https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Logging/WireMockNullLogger.cs) | You can also define the value `WireMockConsoleLogger`. In this case the [WireMockConsoleLogger](https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Logging/WireMockConsoleLogger.cs) is used. | +| `--ProxyURL` | string | | [wiki-proxyandrecordsettings](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#proxyandrecordsettings) | +| `--SaveMapping` | boolean | false | [wiki-proxyandrecordsettings](https://github.com/WireMock-Net/WireMock.Net +/wiki/Settings#proxyandrecordsettings) | +| `--SaveMappingToFile` | boolean | false | [wiki-proxyandrecordsettings](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#proxyandrecordsettings) | +| `--ClientX509Certificate2ThumbprintOrSubjectName` | string| | [wiki-proxyandrecordsettings](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#proxyandrecordsettings) | +| `--BlackListedHeaders` | boolean | false | [wiki-proxyandrecordsettings](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#proxyandrecordsettings) | + ### Option 2 : using the WireMock.Net.StandAlone library using the settings object ```c# class Program @@ -101,4 +115,11 @@ static void Main(string[] args) Console.WriteLine("Press any key to quit"); Console.ReadKey(); } -``` \ No newline at end of file +``` + +## Workaround for Microsoft.Owin.Host.HttpListener exception +Note that when using WireMock in a **NET 4.5x**, **NET 4.6.x** project, you can get this exception when running your console application: + +> Unhandled Exception: System.Exception: Service start failed with error: The server factory could not be located for > the given input: Microsoft.Owin.Host.HttpListener ---> System.MissingMemberException: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener + +The solution is to add the `Microsoft.Owin.Host.HttpListener` (version **4.0.0**) NuGet package to your hosting console application. \ No newline at end of file