This project demonstrates how to create a simple CoreWCF service that communicates over HTTPS and how to consume it from a .NET Framework 4.7 client application. The example helps understand how to establish secure communication between a modern .NET Core service and an older .NET Framework client.
-
Service Application:
-
Built with .NET 8 using CoreWCF.
-
Accessible over HTTPS using BasicHttpBinding.
-
Provides metadata (WSDL) for client-side proxy generation.
-
-
Client Application:
-
Built with .NET Framework 4.7.
-
Consumes the service by adding a service reference based on WSDL.
-
Demonstrates compatibility between .NET Core and .NET Framework.
-
-
Secure Communication: Ensures data encryption during transmission using HTTPS.
-
Compatibility: Enables communication between modern .NET Core services and older .NET Framework clients.
-
WSDL Support: Availability of metadata for easy client proxy generation.
-
.NET 8 SDK (for the service application).
-
.NET Framework 4.7 development tools (for the client application).
-
Visual Studio 2022 or later.
-
Basic knowledge of C# and WCF services.
-
Install NuGet Packages:
- Ensure all necessary NuGet packages are installed for the service project.
-
Build the Service:
- Compile the CoreWCF HTTPS Service project in Visual Studio.
-
Trust the Development Certificate (Development Environment Only):
-
codedotnet dev-certs https --trust
-
This allows the service to run over HTTPS without SSL errors.
-
-
Run the Service:
-
Start the service application.
-
The service will be accessible at https://localhost:5001.
-
-
Add Service Reference:
-
This generates the necessary proxy classes to invoke the service methods.
-
Update Client Configuration:
- Ensure that the client's configuration matches the service's binding settings (use BasicHttpBinding with transport security).
-
Accept SSL Certificates (Development Environment Only):
codeSystem.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
-
Run the Client:
-
Start the client application.
-
The results will be displayed upon successful service invocation.
-
-
Security:
-
In production, always use SSL certificates issued by trusted Certificate Authorities.
-
Do not disable SSL certificate validation in production environments.
-
-
Port Settings:
- The service uses port 5001 for HTTPS. Ensure this port is available and not blocked by firewalls.
-
Compatibility:
- The service uses BasicHttpBinding with transport security to maintain compatibility with older clients.
This example provides a basic template for setting up a CoreWCF service over HTTPS and consuming it from a .NET Framework client. It highlights the key steps necessary for secure communication and demonstrates how to bridge the gap between modern and legacy .NET technologies.