-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e2e176
commit 13a2e5f
Showing
12 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Activation; | ||
using System.ServiceModel.Web; | ||
|
||
namespace WCF.Service.ClassLibrary; | ||
|
||
[ServiceContract] | ||
public interface ICalculator2 | ||
{ | ||
[OperationContract] | ||
[WebGet] | ||
double Add(double n1, double n2); | ||
[OperationContract] | ||
[WebGet] | ||
double Subtract(double n1, double n2); | ||
[OperationContract] | ||
[WebGet] | ||
double Multiply(double n1, double n2); | ||
[OperationContract] | ||
[WebGet] | ||
double Divide(double n1, double n2); | ||
} | ||
|
||
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] | ||
public class CalculatorService2 : ICalculator2 | ||
{ | ||
public double Add(double n1, double n2) | ||
{ | ||
return n1 + n2; | ||
} | ||
public double Subtract(double n1, double n2) | ||
{ | ||
return n1 - n2; | ||
} | ||
public double Multiply(double n1, double n2) | ||
{ | ||
return n1 * n2; | ||
} | ||
public double Divide(double n1, double n2) | ||
{ | ||
return n1 / n2; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
samples/WCF/WCF.Service.ClassLibrary/WCF.Service.ClassLibrary.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>10</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.1.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="System.Net" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.ServiceModel" /> | ||
<Reference Include="System.ServiceModel.Web"> | ||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.ServiceModel.Web.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
21 changes: 21 additions & 0 deletions
21
samples/WCF/WCF.Service.WebApplication/ExampleWCFWebApplication.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="MSBuild.SDK.SystemWeb"> | ||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<MicrosoftNetCompilersToolset_Version>4.1.0</MicrosoftNetCompilersToolset_Version> | ||
<LangVersion>10</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Copyright>Copyright © 2022</Copyright> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="Properties\launchSettings.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\WCF.Service.ClassLibrary\WCF.Service.ClassLibrary.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="System.ServiceModel" /> | ||
<Content Include="Global.asax" /> | ||
<Content Include="*.svc" /> | ||
</ItemGroup> | ||
</Project> |
9 changes: 9 additions & 0 deletions
9
samples/WCF/WCF.Service.WebApplication/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("5FBFD242-8B80-4E81-9D44-B147FA7E0A69")] |
28 changes: 28 additions & 0 deletions
28
samples/WCF/WCF.Service.WebApplication/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:57506", | ||
"sslPort": 44386 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express Local Service": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"launchUrl": "http://localhost:57506/service.svc" | ||
}, | ||
"IIS Express Class Library": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"launchUrl": "http://localhost:57506/service2/Add?n1=420&n2=0.69" | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
samples/WCF/WCF.Service.WebApplication/Services/CalculatorService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.ServiceModel; | ||
|
||
namespace ExampleWCFWebApplication.Services; | ||
|
||
[ServiceContract] | ||
public interface ICalculator | ||
{ | ||
[OperationContract] | ||
double Add(double n1, double n2); | ||
[OperationContract] | ||
double Subtract(double n1, double n2); | ||
[OperationContract] | ||
double Multiply(double n1, double n2); | ||
[OperationContract] | ||
double Divide(double n1, double n2); | ||
} | ||
|
||
public class CalculatorService : ICalculator | ||
{ | ||
public double Add(double n1, double n2) | ||
{ | ||
return n1 + n2; | ||
} | ||
public double Subtract(double n1, double n2) | ||
{ | ||
return n1 - n2; | ||
} | ||
public double Multiply(double n1, double n2) | ||
{ | ||
return n1 * n2; | ||
} | ||
public double Divide(double n1, double n2) | ||
{ | ||
return n1 / n2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --> | ||
|
||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | ||
<!-- | ||
In the example below, the "SetAttributes" transform will change the value of | ||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator | ||
finds an attribute "name" that has a value of "MyDB". | ||
<connectionStrings> | ||
<add name="MyDB" | ||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" | ||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> | ||
</connectionStrings> | ||
--> | ||
<system.web> | ||
<!-- | ||
In the example below, the "Replace" transform will replace the entire | ||
<customErrors> section of your web.config file. | ||
Note that because there is only one customErrors section under the | ||
<system.web> node, there is no need to use the "xdt:Locator" attribute. | ||
<customErrors defaultRedirect="GenericError.htm" | ||
mode="RemoteOnly" xdt:Transform="Replace"> | ||
<error statusCode="500" redirect="InternalError.htm"/> | ||
</customErrors> | ||
--> | ||
</system.web> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --> | ||
|
||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | ||
<!-- | ||
In the example below, the "SetAttributes" transform will change the value of | ||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator | ||
finds an attribute "name" that has a value of "MyDB". | ||
<connectionStrings> | ||
<add name="MyDB" | ||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" | ||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> | ||
</connectionStrings> | ||
--> | ||
<system.web> | ||
<compilation xdt:Transform="RemoveAttributes(debug)" /> | ||
<!-- | ||
In the example below, the "Replace" transform will replace the entire | ||
<customErrors> section of your web.config file. | ||
Note that because there is only one customErrors section under the | ||
<system.web> node, there is no need to use the "xdt:Locator" attribute. | ||
<customErrors defaultRedirect="GenericError.htm" | ||
mode="RemoteOnly" xdt:Transform="Replace"> | ||
<error statusCode="500" redirect="InternalError.htm"/> | ||
</customErrors> | ||
--> | ||
</system.web> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- | ||
For more information on how to configure your ASP.NET application, please visit | ||
https://go.microsoft.com/fwlink/?LinkId=169433 | ||
--> | ||
<configuration> | ||
<system.web> | ||
<compilation debug="true" targetFramework="4.8" /> | ||
<httpRuntime targetFramework="4.8" /> | ||
</system.web> | ||
<system.codedom> | ||
<compilers> | ||
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> | ||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> | ||
</compilers> | ||
</system.codedom> | ||
<system.webServer> | ||
<modules runAllManagedModulesForAllRequests="true"> | ||
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> | ||
</modules> | ||
<handlers> | ||
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd"/> | ||
</handlers> | ||
</system.webServer> | ||
<system.serviceModel> | ||
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> | ||
|
||
<services> | ||
<service name="ExampleWCFWebApplication.Services.CalculatorService" behaviorConfiguration="CalculatorServiceBehaviors"> | ||
|
||
<!-- This endpoint is exposed at the base address provided by host: http://localhost/service.svc --> | ||
<endpoint address="" | ||
binding="wsHttpBinding" | ||
contract="ExampleWCFWebApplication.Services.ICalculator" /> | ||
|
||
<!-- The mex endpoint is exposed at http://localhost/service.svc/mex --> | ||
<endpoint address="mex" | ||
binding="mexHttpBinding" | ||
contract="IMetadataExchange" /> | ||
</service> | ||
</services> | ||
|
||
<behaviors> | ||
<serviceBehaviors> | ||
<behavior name="CalculatorServiceBehaviors"> | ||
<!-- Add the following element to your service behavior configuration. --> | ||
<serviceMetadata httpGetEnabled="true" /> | ||
</behavior> | ||
</serviceBehaviors> | ||
</behaviors> | ||
</system.serviceModel> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%@ Application Language="C#" %> | ||
<%@ Import Namespace="System.Web.Routing" %> | ||
<%@ Import Namespace="System.ServiceModel.Activation" %> | ||
<%@ Import Namespace="System.ServiceModel.Web " %> | ||
|
||
<script RunAt="server"> | ||
void Application_Start(object sender, EventArgs e) | ||
{ | ||
RegisterRoutes(RouteTable.Routes); | ||
} | ||
private void RegisterRoutes(RouteCollection routes) | ||
{ | ||
routes.Add(new ServiceRoute("service2", new WebServiceHostFactory(), typeof(WCF.Service.ClassLibrary.CalculatorService2))); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ServiceHost language="c#" Debug="true" Service="ExampleWCFWebApplication.Services.CalculatorService"%> |