Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the compatibility between WCF Service and ASMX Service in ASP.NET

Shulou Source: shulou.com Published: 2022-06-02 10:02:20 10月26日 Update

In this issue, the editor will bring you about how to understand the compatibility of WCF services and ASMX services in ASP.NET. The article is rich in content and analyzes and describes it from a professional point of view. I hope you can get something after reading this article.

As you know from the previous operation, when you create a new WCF service for an asp.net AJAX program, the service class is decorated with the AspNetCompatibilityRequirements attribute by default. Now, let's make a brief analysis.

Analysis of WCF service and ASMX service in ASP.NET:

[ServiceContract] [AspNetCompatibilityRequirements (RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)] public class TimeService {. }

Although designed for independent transport, WCF services can actually work in a way that is very similar to ASMX services when applied in an asp.net AJAX application environment. With this AspNetCompatibilityRequirements attribute, we can instruct WCF to work using the same model as the ASMX service. In practice, this setting indicates that when a WCF service is activated, the runtime checks the declared endpoints and ensures that they all use the Web HTTP binding model.

Good compatibility with ASMX services makes it possible to access asp.net objects such as HttpContext objects and other inherent asp.net objects in WCF services.

Note that there are at least two things you need to achieve compatibility between WCF services and ASMX services in ASP.NET. In the configuration file web.config, you need a declarative definition similar to the following:

< system.serviceModel>

:

< serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

< /system.serviceModel>

Second, developers need to explicitly choose the compatibility mode of a given WCF service, which is done by using the service AspNetCompatibilityRequirements property.

The service requirements requested in the asp.net AJAX application must be configured on the server side accordingly. To sum up, in asp.net applications, there are two main software technologies that can be used to build services, namely ASMX Web services and WCF services. Among them, WCF service already includes ASMX Web service. However, it must be clear that AJAX communication requires the use of JSON data strings to transfer data back and forth between the client and the server. It is an easy task in the era of asp.net AJAX extension 1.0 or in asp.net 3.5 to adjust the asp.net runtime so that ASMX Web services support JSON. However, it is slightly more complicated to implement the transmission of JSON data format for richer WCF services. This is why WCF can be used to build AJAX back-end services only in asp.net 3.5.

The above is the editor to share with you how to understand the compatibility of WCF services and ASMX services in ASP.NET. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Services compatibility programs analysis applications objects properties applications data transmission content actual situation indication mode moment server model work run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker NVidia Huawei vpn