Skip to content

Commit 66e4225

Browse files
claudiamurialdocmurialdoClaudia Beatriz Murialdo Garrone
authored
Imported the GxSoapHandler codebase (#1065)
* Imported the GxSoapHandler codebase from https://github.com/genexuslabs/GxSoapHandlerNet * Update README.md * Removed src directory. * Update README.md * Update README.md * Update README.md * Path fixed. * Formatting * Keep src directory. * Fix src directory --------- Co-authored-by: cmurialdo <c.murialdo@global.com> Co-authored-by: Claudia Beatriz Murialdo Garrone <c.murialdo@globant.com>
1 parent d714445 commit 66e4225

File tree

4 files changed

+135
-1
lines changed

4 files changed

+135
-1
lines changed

dotnet/DotNetStandardClasses.sln

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogTest", "test\benchmarks\
263263
EndProject
264264
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccessTokenController_Test", "test\NativeAccessControllerTest\AccessTokenController_Test.csproj", "{A5589382-DB6F-4450-AE2B-6C6AA1643EF1}"
265265
EndProject
266+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ws", "ws", "{B5C28D81-BCD9-4B29-9B68-EDD81D1018D5}"
267+
EndProject
268+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F8959289-4ED7-430C-97B7-FAAA29829708}"
269+
EndProject
270+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GxSoapHandler", "src\extensions\ws\src\GxSoapHandler\GxSoapHandler.csproj", "{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}"
266271
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Functions", "Functions", "{E59B3248-4C26-4DB0-96CB-67437319E22B}"
267272
EndProject
268273
Global
@@ -643,6 +648,10 @@ Global
643648
{A5589382-DB6F-4450-AE2B-6C6AA1643EF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
644649
{A5589382-DB6F-4450-AE2B-6C6AA1643EF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
645650
{A5589382-DB6F-4450-AE2B-6C6AA1643EF1}.Release|Any CPU.Build.0 = Release|Any CPU
651+
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
652+
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Debug|Any CPU.Build.0 = Debug|Any CPU
653+
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Release|Any CPU.ActiveCfg = Release|Any CPU
654+
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Release|Any CPU.Build.0 = Release|Any CPU
646655
EndGlobalSection
647656
GlobalSection(SolutionProperties) = preSolution
648657
HideSolutionNode = FALSE
@@ -690,7 +699,7 @@ Global
690699
{E2547AA5-1ECD-45EF-975F-0E467CA23201} = {F900A4AD-7249-41B4-B918-CB9E8C73747C}
691700
{C8CB3B0D-2FDB-49D4-A739-BF0BDCC8979F} = {FE3D0F5E-DEFF-4D37-89EB-FD992ABAEE30}
692701
{7A775A8B-646D-4FE6-8952-9F9C8B38B924} = {914600BD-A02B-414E-AC84-50E60AA64222}
693-
{FE3D0F5E-DEFF-4D37-89EB-FD992ABAEE30} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
702+
{FE3D0F5E-DEFF-4D37-89EB-FD992ABAEE30} = {3C0E779F-1949-40AC-AE18-5D59101B24CB}
694703
{CEE05123-1973-4F54-BC44-AFFB4373936A} = {F900A4AD-7249-41B4-B918-CB9E8C73747C}
695704
{6E82437D-8CF2-4206-B4A8-7691B431A45A} = {F1E13DF4-9F50-41A2-9DC3-04B673B21032}
696705
{721C71DA-0E1C-49C1-88AE-17A97AA255D3} = {F1E13DF4-9F50-41A2-9DC3-04B673B21032}
@@ -769,6 +778,9 @@ Global
769778
{46DAAFD1-FAF5-4904-8EC5-406BE04E5538} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
770779
{A1DBDCE0-4F09-445F-A202-9B260CDD46CF} = {46DAAFD1-FAF5-4904-8EC5-406BE04E5538}
771780
{A5589382-DB6F-4450-AE2B-6C6AA1643EF1} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
781+
{B5C28D81-BCD9-4B29-9B68-EDD81D1018D5} = {C6AFB6A3-FF0B-4970-B1F1-10BCD3D932B2}
782+
{F8959289-4ED7-430C-97B7-FAAA29829708} = {B5C28D81-BCD9-4B29-9B68-EDD81D1018D5}
783+
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32} = {F8959289-4ED7-430C-97B7-FAAA29829708}
772784
{E59B3248-4C26-4DB0-96CB-67437319E22B} = {41E1D031-799F-484F-85DE-7A30AF1A6FBA}
773785
EndGlobalSection
774786
GlobalSection(ExtensibilityGlobals) = postSolution
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.ServiceModel;
3+
using GeneXus.Utils;
4+
using System.Security.Cryptography.X509Certificates;
5+
using System.ServiceModel.Security;
6+
public class GxSoapHandler
7+
{
8+
public void Setup(string eoName, GxLocation loc, object serviceClient)
9+
{
10+
string Parameters = loc.Configuration.ToString();
11+
string[] Parameter = Parameters.Split(';');
12+
string IdentStr = Parameter[1];
13+
string DGICert = Parameter[2];
14+
string ClientCert = Parameter[3];
15+
string Clientpassword = Parameter[4];
16+
string ServUri = Parameter[5];
17+
18+
if (eoName == "WS_eFactura") // Name of the external object to filter, in this example EfacturaUy
19+
{
20+
//Replace ISdtWS_eFacturaDummy by the appropiate name which is contained in *.Programs.Common.dll, which must be added as a reference to the project
21+
ClientBase<ISdtWS_eFacturaDummy> svc = serviceClient as ClientBase<ISdtWS_eFacturaDummy>;
22+
23+
svc.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
24+
25+
//Declare the objects to store the Certificates
26+
X509Certificate2 crtCLI;
27+
X509Certificate2 crtDGI;
28+
29+
crtCLI = new X509Certificate2(ClientCert.Trim(), Clientpassword.Trim());
30+
crtDGI = new X509Certificate2(DGICert.Trim());
31+
32+
//Add the certificates to the web service client
33+
svc.ClientCredentials.ClientCertificate.Certificate = crtCLI;
34+
svc.ClientCredentials.ServiceCertificate.DefaultCertificate = crtDGI;
35+
svc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
36+
37+
38+
//Create the WS address, which includes the URI and the DNS (the CN of the DGI certificate)
39+
svc.Endpoint.Address = new EndpointAddress(new Uri(ServUri.Trim()),EndpointIdentity.CreateDnsIdentity(IdentStr.Trim()));
40+
41+
42+
}
43+
}
44+
internal interface ISdtWS_eFacturaDummy
45+
{
46+
}
47+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net462</TargetFramework>
5+
<OutputType>Library</OutputType>
6+
<RootNamespace>GxSoapHandler</RootNamespace>
7+
<AssemblyName>GxSoapHandler</AssemblyName>
8+
<IsPackable>false</IsPackable>
9+
<SignAssembly>false</SignAssembly>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\..\..\dotnetframework\GxClasses\GxClasses.csproj"/>
14+
<Reference Include="System.ServiceModel">
15+
<RequiredTargetFramework>3.0</RequiredTargetFramework>
16+
</Reference>
17+
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.34.0"/>
18+
<Reference Include="System.ServiecModel"/>
19+
<Reference Include="System.IdentityModel" />
20+
<!--Reference Include="GeneXus.Programs.Common">
21+
<HintPath>C:\MyKB\CSharpModel\web\bin\GeneXus.Programs.Common.dll</HintPath>
22+
</Reference-->
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# GxSoapHandler
2+
3+
## Component for Rewriting Web Service Credentials
4+
5+
This component allows you to overwrite web service credentials at runtime using location data type.
6+
7+
8+
## Overview
9+
Starting with GeneXus v15 Upgrade 11, a new non-standard property, location.Configuration, has been introduced to facilitate dynamic configuration of web service parameters.
10+
11+
## Example Implementation
12+
In GeneXus, you can configure and use the web service credentials as follows:
13+
14+
```
15+
&location = GetLocation("WS_eFactura")
16+
&location.Configuration= "Name;IDENTITY;PATH_CERT_DGI; PATH_ CERT_CLIENT;PASSWORD;URI"
17+
// This property accepts a semicolon-separated string with the configuration details
18+
19+
// Load a query as a test for DGI
20+
&pWS_eFacturaData.xmlData.FromString("")
21+
&pWS_eFacturaDataResult = &WS_eFactura.EFACRECEPCIONSOBRE(&pWS_eFacturaData)
22+
&longvar = &pWS_eFacturaDataResult.ToXml()
23+
```
24+
25+
26+
## Building the Assembly
27+
To enable dynamic credential modification, checkout this repo and create the GxSoapHandler.dll assembly as follows:
28+
29+
1. Include a reference to ``<KB Namespace>``.Programs.Common.dll in GxSoapHandler.csproj and replace ISdtWS_eFacturaDummy in GxSoapHandler.cs by the correct web service name.
30+
31+
2. Build the assembly with one of the following commands:
32+
```
33+
msbuild /t:restore;build /p:Configuration=Release dotnet\src\extensions\ws\src\GxSoapHandler\GxSoapHandler.csproj
34+
```
35+
or
36+
```
37+
dotnet build -c Release dotnet\src\extensions\ws\src\GxSoapHandler\GxSoapHandler.csproj
38+
```
39+
40+
3. Copy dotnet\src\extensions\ws\src\GxSoapHandler\bin\Release\net462\GxSoapHandler.dll to the web\bin folder.
41+
42+
43+
## Configuration
44+
Additionally, ensure that the following line is added to the web.config file to enable the new credential handler:
45+
46+
47+
```
48+
<add key="NativeChannelConfigurator" value="GxSoapHandler" />
49+
```
50+

0 commit comments

Comments
 (0)