In XEV1 U2, WCF support has been implemented for objects that are exposed as a web service and for external objects that import services.
Compatibility: This replaces the previous implementation of WSE 3.0. After U2 GXXev1 installed, if using WSE, we must move to WCF.
Windows Communication Foundation (WCF) is an architecture that makes it possible to provide and consume services easily and powerfully in .NET. The architecture is based on the concept of "endpoint" (point of access); a WCF service is a program that exposes a set of endpoints, and a WCF client is a program that exchanges messages with one or more endpoints.
An endpoint has three components:
- Address – indicates where the service is located
- Binding – indicates how the service communicates; that is to say, which transport protocol is used (HTTP, TCP, etc) and the type of security (SSL, WS-Security, etc). The .NET Framework has a set of predefined bindings that represent the most common cases, which simplifies configuration.
- Contract – indicates what is being communicated, that is to say, the structure of messages and communication patterns (one-way, duplex, etc.)
To use this feature in GeneXus with the .Net generator, we have the "Use Native Soap" property at the object and generator level. It makes it possible to indicate when to generate, using the native support.
To use this property, you have to compile with .Net framework 3.5 or higher ("Compiler path" property).
It applies to objects that consume or expose web services:
- Procs with SOAP call protocol
- Data Providers
- Business Components
- External Objects
The default value is NO, for reasons of compatibility with previous versions of the .Net generator.
When this property is enabled, the objects that consume and expose web services are generated with the infrastructure that makes it possible to use the WCF serialization and communication. In addition, the necessary configuration is generated to provide or access WCF services; for the services provided, a file with .svc extension is also generated that works as a point of access to the WCF (the services exposed with WCF have "svc" extension).
With this generator, ALL SDTs generate the necessary code for native serialization and WCF (regardless of whether they are used for native serialization or with the serialization generated by GX), which requires .Net Framework 3.5 or higher.
An important concept in WCF is the possibility to modify the service interconnection parameters by modifying configuration files. This makes it possible to configure interoperability parameters at deployment time instead of doing it when programming the application. GX generates the basic configuration for using the services, and this configuration can later be modified by the developer at deployment time (for example, to add security). This is done in the web.config. It is a rather powerful scheme and you can find more information about it at: msdn.microsoft.com/en-us/library/ms730120.aspx
Configuration of the service provider
For the objects exposed as a web service and generated with WCF support, the corresponding configuration is generated in the web.config, as shown below:
Address – address of the web site where the service is being executed.
Binding - "basicHttpBinding" is used, which implies: HTTP transport, text messages with UTF-8 encoding, no security at the message level (even though it can be configured within the binding)
Contract – One input message and one output message built according to the services parameters, wrapped in all cases.
Example of this configuration in the web.config:
<service name="GeneXus.Programs.asoapproc_services" behaviorConfiguration="ServiceDefaultBehavior">
<endpoint address="" binding="basicHttpBinding" contract="GeneXus.Programs.asoapproc_services" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<serviceMetadata httpGetEnabled="true" />
This configuration also includes the possibility to access the service to query metadata, whether in MEX (Metadata Exchange Format) or WSDL format.
Configuration of the service client
For the external objects that access the imported web services, the endpoints are configured in the same way. For example, to communicate with a .NET service (ASMX):
This section can be found in WCFClient.config file. for web applications is necessary rewrite on "system.serviceModel" of web.config file
For more information about WCF : http://msdn.microsoft.com/en-us/library/aa480190.aspx or http://msdn.microsoft.com/en-us/library/ms731354(v=VS.100).aspx
For more information about how to migrate form WSE to WCF: http://msdn.microsoft.com/es-es/library/ms732008.aspx