Skip to content

Commit 0e75504

Browse files
claudiamurialdoclaudiamurialdo
andauthored
Define SetSoapContext and GetSoapContext as independent from GxContext. (#1220)
* Define SetSoapContext and GetSoapContext as independent from GxContext. * Ensure OperationContext is not null before accessing extensions --------- Co-authored-by: claudiamurialdo <c.murialdo@globant.com>
1 parent 3e9c3bf commit 0e75504

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace GeneXus.Application
1414
using System.ServiceModel.Web;
1515
using GeneXus.UserControls;
1616
using System.Net.Http.Headers;
17+
using System.ServiceModel;
1718
#else
1819
using Microsoft.AspNetCore.Http;
1920
using GxClasses.Helpers;
@@ -4128,10 +4129,36 @@ public string ClientID
41284129
}
41294130
}
41304131

4132+
4133+
#if NETCORE
41314134
public GXSOAPContext SoapContext { get; set; }
4135+
#else
4136+
public GXSOAPContext SoapContext
4137+
{
4138+
get
4139+
{
4140+
return HttpHelper.GetSoapContext();
4141+
}
4142+
set
4143+
{
4144+
HttpHelper.SetSoapContext(value);
4145+
}
4146+
}
4147+
4148+
#endif
4149+
41324150

41334151
#endregion
41344152
}
4153+
#if !NETCORE
4154+
public class RequestMessageExtension : IExtension<OperationContext>
4155+
{
4156+
public GXSOAPContext SOAPContext { get; set; }
4157+
4158+
public void Attach(OperationContext owner) { }
4159+
public void Detach(OperationContext owner) { }
4160+
}
4161+
#endif
41354162
public class GxXmlContext
41364163
{
41374164
GXXMLReader _XMLR;

dotnet/src/dotnetframework/GxClasses/Helpers/HttpHelper.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,33 @@ internal static string JsonQuote(string value, bool addDoubleQuotes=false)
689689
return "\"" + text + "\"";
690690
}
691691
}
692-
692+
#if !NETCORE
693+
public static void SetSoapContext(GXSOAPContext value)
694+
{
695+
if (OperationContext.Current != null)
696+
{
697+
RequestMessageExtension ext = OperationContext.Current.Extensions.Find<RequestMessageExtension>();
698+
if (ext == null)
699+
{
700+
ext = new RequestMessageExtension();
701+
OperationContext.Current.Extensions.Add(ext);
702+
}
703+
ext.SOAPContext = value;
704+
}
705+
}
706+
internal static GXSOAPContext GetSoapContext()
707+
{
708+
if (OperationContext.Current != null)
709+
{
710+
RequestMessageExtension ext = OperationContext.Current.Extensions.Find<RequestMessageExtension>();
711+
if (ext != null)
712+
{
713+
return ext.SOAPContext;
714+
}
715+
}
716+
return null;
717+
}
718+
#endif
693719
}
694720
#if NETCORE
695721
public class HttpCookieCollection : Dictionary<string, HttpCookie>

0 commit comments

Comments
 (0)