Skip to content

Commit

Permalink
Run examples on different ports and urls
Browse files Browse the repository at this point in the history
  • Loading branch information
capslocky committed Jul 14, 2018
1 parent da1e063 commit 5678558
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Install-Package WcfSoapLogger


## Usage examples ##
The repository contains [usage examples](/src/UsageExamples) covering different scenarios.
The repository contains **[usage examples](/src/UsageExamples)** covering different scenarios.
To clone run this command or download as [zip file](https://github.com/capslocky/WcfSoapLogger/archive/master.zip).
```
git clone https://github.com/capslocky/WcfSoapLogger.git
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleAlpha/Client/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system.serviceModel>

<client>
<endpoint address="http://localhost:5580/weatherService"
<endpoint address="http://localhost:5581/weatherServiceAlpha"
binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWeatherService"
contract="CommonClient.IWeatherService" />
</client>
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleAlpha/Service/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<service name="CommonService.WeatherServiceEurope" behaviorConfiguration="weatherServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:5580/weatherService" />
<add baseAddress="http://localhost:5581/weatherServiceAlpha" />
</baseAddresses>
</host>
<endpoint address=""
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleAlpha/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static void Main()

Console.WriteLine("Service started.");

Process.Start("http://localhost:5580/weatherService");
Process.Start("http://localhost:5581/weatherServiceAlpha");

Console.WriteLine("Press Enter to stop.");
Console.ReadLine();
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleBeta/Client/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system.serviceModel>

<client>
<endpoint address="http://localhost:5580/weatherService"
<endpoint address="http://localhost:5582/weatherServiceBeta"
binding="customBinding" bindingConfiguration="soapLoggerBinding"
contract="CommonClient.IWeatherService" />
</client>
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleBeta/Service/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<service name="CommonService.WeatherServiceEurope" behaviorConfiguration="weatherServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:5580/weatherService" />
<add baseAddress="http://localhost:5582/weatherServiceBeta" />
</baseAddresses>
</host>
<endpoint address=""
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleBeta/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private static void Main() {

Console.WriteLine("Service started.");

Process.Start("http://localhost:5580/weatherService");
Process.Start("http://localhost:5582/weatherServiceBeta");

Console.WriteLine("Press Enter to stop.");
Console.ReadLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public ForecastCalculator(ReportRepository reportRepository)
public WeatherReport[] GetForecast(string location, int days)
{
var lastReport = _reportRepository.GetLastByLocation(location);

if (lastReport == null)
{
return new WeatherReport[0];
}

var list = new List<WeatherReport>();

var memoryStream = new MemoryStream();
Expand All @@ -45,6 +51,5 @@ private float GetRandomValue(float minimum, float maximum)
{
return (float)_random.NextDouble() * (maximum - minimum) + minimum;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace CommonService
{
Expand All @@ -13,6 +14,12 @@ public long Add(WeatherReport report)
{
report.Id = _reports.Count + 1;
_reports.Add(report);

if (report.Id % 5 == 0)
{
throw new InvalidOperationException($"Oops! Report with ID '{report.Id}' produced an error on server. Look for its Fault_Response.xml in log folder.");
}

return report.Id;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public virtual WeatherReport GetLastReportByLocation(string location)

var lastReport = _reportRepository.GetLastByLocation(location);

if (lastReport == null)
{
Console.WriteLine("GetLastReport for " + location + ": null");
return null;
}

Console.WriteLine("GetLastReport for " + location + ": returning Report ID = " + lastReport.Id);
return lastReport;
}
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleDelta/Client/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system.serviceModel>

<client>
<endpoint address="https://wcf.mozilla.org:5581/weatherService"
<endpoint address="https://wcf.mozilla.org:5584/weatherServiceDelta"
binding="customBinding" bindingConfiguration="soapLoggerBindingHttps"
contract="CommonClient.IWeatherService" />
</client>
Expand Down
4 changes: 2 additions & 2 deletions src/UsageExamples/ExampleDelta/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ private static void Main()

var serviceClient = new WeatherServiceClient();

serviceClient.ClientCredentials.UserName.UserName = "admin";
serviceClient.ClientCredentials.UserName.Password = "password";
serviceClient.ClientCredentials.UserName.UserName = "neo";
serviceClient.ClientCredentials.UserName.Password = "matrix";

var randomDataClient = new RandomDataClient(serviceClient);
randomDataClient.StartThreads();
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleDelta/Service/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<service name="CommonService.WeatherServiceEurope" behaviorConfiguration="weatherServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://wcf.mozilla.org:5581/weatherService" />
<add baseAddress="https://wcf.mozilla.org:5584/weatherServiceDelta" />
</baseAddresses>
</host>
<endpoint address=""
Expand Down
6 changes: 3 additions & 3 deletions src/UsageExamples/ExampleDelta/Service/LinkSSLtoPort.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ rem Linking SSL certificate with port
rem 'appid' is any random guid, 'certhash' is thumbprint of certificate
rem run this as admin

netsh http add sslcert ipport=0.0.0.0:5581 certstore=MY certhash=77ce7ba50ea75cdaa70c097301ea1b69ba18dbbe appid={365F3B03-46D7-463B-B8AF-BE8456760A63}
netsh http add sslcert ipport=0.0.0.0:5584 certstore=MY certhash=77ce7ba50ea75cdaa70c097301ea1b69ba18dbbe appid={365F3B03-46D7-463B-B8AF-BE8456760A63}

netsh http show sslcert ipport=0.0.0.0:5581
netsh http show sslcert ipport=0.0.0.0:5584

rem netsh http delete sslcert ipport=0.0.0.0:5581
rem netsh http delete sslcert ipport=0.0.0.0:5584

pause
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleDelta/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static void Main()

Console.WriteLine("Service started.");

Process.Start("https://wcf.mozilla.org:5581/weatherService");
Process.Start("https://wcf.mozilla.org:5584/weatherServiceDelta");

Console.WriteLine("Press Enter to stop.");
Console.ReadLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public override void Validate(string userName, string password)
throw new ArgumentNullException();
}

if (userName != "admin" || password != "password")
if (userName != "neo" || password != "matrix")
{
throw new SecurityTokenException("Unknown Username or Incorrect Password.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleEpsilon/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static void Main()
Console.ReadKey();
Console.WriteLine();

const string serviceUrl = "http://localhost:5580/weatherService";
const string serviceUrl = "http://localhost:5585/weatherServiceEpsilon";
var address = new EndpointAddress(serviceUrl);

const string logPath = @"C:\SoapLog\Epsilon\Client";
Expand Down
4 changes: 2 additions & 2 deletions src/UsageExamples/ExampleEpsilon/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private static void Main()
{
Console.Title = "ExampleEpsilon.Service";

const string baseAddress ="http://localhost:5580/weatherService";
const string baseAddress = "http://localhost:5585/weatherServiceEpsilon";
var serviceHost = new ServiceHost(typeof(WeatherServiceEurope), new Uri(baseAddress));

serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;
Expand Down Expand Up @@ -47,7 +47,7 @@ private static void Main()

Console.WriteLine("Service started.");

Process.Start("http://localhost:5580/weatherService");
Process.Start("http://localhost:5585/weatherServiceEpsilon");

Console.WriteLine("Press Enter to stop.");
Console.ReadLine();
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleGamma/Client/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system.serviceModel>

<client>
<endpoint address="http://localhost:5580/weatherService"
<endpoint address="http://localhost:5583/weatherServiceGamma"
binding="customBinding" bindingConfiguration="soapLoggerBinding"
contract="CommonClient.IWeatherService" />
</client>
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleGamma/Service/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<service name="CommonService.CustomHandling.WeatherServiceEuropeCustomHandler" behaviorConfiguration="weatherServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:5580/weatherService" />
<add baseAddress="http://localhost:5583/weatherServiceGamma" />
</baseAddresses>
</host>
<endpoint address=""
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/ExampleGamma/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static void Main()

Console.WriteLine("Service started.");

Process.Start("http://localhost:5580/weatherService");
Process.Start("http://localhost:5583/weatherServiceGamma");

Console.WriteLine("Press Enter to stop.");
Console.ReadLine();
Expand Down
2 changes: 1 addition & 1 deletion src/UsageExamples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
1. Clone the repository or download as [zip file](https://github.com/capslocky/WcfSoapLogger/archive/master.zip).
2. Open and build solution **\src\Library** (so you will have \WcfSoapLogger\bin\Debug\WcfSoapLogger.dll)
3. Open and build solution **\src\UsageExamples\ExampleCommon** (it contains common example code as dll)
4. Open example solution and set to launch both service and client
4. Open any example solution **as admin** and set it to launch both service and client
5. Build and run solution, it will automatically open service url and logging folder


Expand Down

0 comments on commit 5678558

Please sign in to comment.