A Soap service is consumed from an environment with the Use Native Soap property set to True. A mechanism is provided that allows doing something similar to the location data type, but extending its functionalities, without the need to load this type of data with language particularities.
Allows you to modify or add data in a SOAP service request, for example, to add credentials, certificates, URL change, etc.
For this implementation to take effect, you must edit the web.config and add the line.
<add key="NativeChannelConfigurator" value="GxSoapHandler"/>
You must also set a Configuration (NonStandard) property to the location data type, and there send the necessary parameters that you want to add/modify, either as a string, SDT or object.
You could program something like this:
&location = GetLocation("WS_eFactura")
// Load a sample Invoice
&pWS_eFacturaDataResult = &WS_eFactura.EFACRECEPCIONSOBRE(&pWS_eFacturaData)
&longvar = &pWS_eFacturaDataResult.ToXml()
Finally, an assembly must be created (native .Net object) that will be invoked before the service call. This is where the parameters sent by the GeneXus program are overwritten.
An example of this code can be seen at https://github.com/genexuslabs/GxSoapHandlerNet
As an example, if you only want to overwrite the URL, you can program it like this:
public class GxSoapHandler
public void Setup( string eoName, GxLocation loc, object serviceClient)
if (eoName == "WS_eFactura" && loc.Configuration=="xxxxxxx")
ClientBase<ISdtService1> svc = serviceClient as ClientBase<ISdtService1>;
svc.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://efactura.dgi.gub.uy:443/efactura/ws_efactura"); //changes the service URL
It allows you to add data to the SOAP request, for example, to send a SAM-L token for authentication.
This is implemented through an external jar. If the classpath contains a class called com.genexus.util.GXSoapHandler a static method of that class called setHandlers will be invoked before the service call.
This method has the following parameters:
public static void setHandlers(Integer remoteHandle, com.genexus.ModelContext context, String serviceName, javax.xml.ws.BindingProvider bProvider)
Download a sample project: https://github.com/genexuslabs/GxSoapHandlerJava