Updated WireMock as a standalone process (markdown)

Stef Heyenrath
2019-08-15 20:46:53 +02:00
parent c419caaffa
commit d7ca5cad32

@@ -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();
}
```
```
## 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.