WCF, Net remoting, Web service concepts and differences

Source: Internet
Author: User
Tags http authentication soap msmq

Windows Communications Foundation (Windows Communication FOUNDATION,WCF) is a software development package (software development KIT,SDK) that is based on the development and deployment of services under the Windows platform.

WCF is the integrator of Microsoft's programming technology for distributed processing, which integrates DCOM, Remoting, Web Service, WSE, and MSMQ to reduce the learning curve of distributed system developers and unify development standards.

WCF is built on the. NET Framework 2.0 and is included in the. NET 3.0/3.5. WCF is not included in 2005, but when WinFX Runtime components is installed, we can develop and create WCF programs in the Visual Studio 2005 environment.

Respect for data sources. The following from the Web http://www.cppblog.com/mzty/archive/2007/10/24/35068.html
A WCF
Broadly speaking, WCF has the following advantages:

1. Unity

As already described, WCF is the integration of technologies such as Asmx,.net remoting,enterprise service,wse,msmq. Because WCF is written entirely by managed code, the application that develops WCF is not much different from developing other. NET applications, and we can still use WCF to create service-oriented applications like creating object-oriented applications.

2. Interoperability

Because the most basic communication mechanism for WCF is soap, this guarantees interoperability between systems, even if it is running in a different context. This communication can be based on the. NET-to. NET communication.

You can communicate across processes, across machines, and even across platforms, as long as you support standard Web Service, such as a Java EE application server (such as Websphere,weblogic). The application can run under the Windows operating system, or it can run on other operating systems, such as Sun solaris,hp unix,linux and so on.

3. Safety and trustworthiness

Ws-security,ws-trust and Ws-secureconversation are added to the SOAP message for user authentication, data integrity verification, data privacy and many other security factors.

Added ws-reliablemessaging in the header of soap to allow trustworthy end-to-end communication. In the case of Ws-coordination and Ws-atomictransaction-based information exchanged in SOAP format, two-phase transaction commits (two-phase commit transactions) are supported.

Many of the above Ws-policy are supported in WCF. For messaging, SOAP is the basic Protocol for Web service, which contains the message header (header) and the body of the message (body). In the message header, the address information that Ws-addressing uses to locate the SOAP message is defined, along with the MTOM (message transfer optimization mechanism, MSG transmission optimization mechanism).

4. Compatibility

WCF takes full account of compatibility with legacy systems. Installing WCF does not affect legacy technologies such as ASMX and. Net Remoting. Even for WCF and ASMX, although both use SOAP, WCF-developed-based applications can still interact directly with ASMX.

Operation mechanism of two WebService

First the client from the server to the WebService WSDL, while the client claims a proxy class, this proxy class is responsible for the request and response with the WebService server, When a data (XML format) is encapsulated in a SOAP-formatted stream to the server, a process object is generated and the SOAP packet that receives the request is parsed, then the thing is processed, and the result is soap-wrapped after processing ends. And then the package as a response sent to the client proxy class, similarly, the proxy class will also parse the SOAP packet, followed by subsequent operations.

Three. NET Remoting

is a technology developed on the basis of DCOM, its main purpose is to achieve cross-platform, cross-language, penetrate the enterprise firewall, which is also his basic characteristics, unlike WebService, it supports HTTP and TCP channels, and it can not only transfer XML-formatted SOAP packets, It is also possible to transfer a binary stream in the traditional sense, which makes it more efficient and more flexible. And it does not depend on IIS, users can develop (development) themselves and deploy (Dispose) their favorite host server, so in terms of these aspects webservice is actually a special case of. Netemoting.

Difference:

1, remoting can flexibly define its based on the Protocol, such as HTTP,TCP, if defined as HTTP, and Web service is the same, but WebService is stateless, using remoting generally like to define TCP, so than the web The service is somewhat more efficient and stateful.

2, remoting is not a standard, and Web service is standard.

3, remoting generally need to start with a WinForm or Windows service, you can also use IIS deployment, and Web service must be started in IIS.

4, in the Vs.net development environment, dedicated to the invocation of the Web service is encapsulated, used more convenient than remoting.

The 5 NET remoting can only be applied to the MS. NET Framework, requiring the client to install the framework, but the webservice is platform-independent, cross-language (as long as XML-capable languages are available) and penetrate corporate firewalls.

Distributed Application Design: ASP. NET Web Services and Remoting

The ASP. NET WEB Service is biased towards the XML Schema type system, providing a simple programming model with a wide range of cross-platform support. The Remoting is biased towards the runtime type system, providing a more complex programming model with a much smaller scope. This fundamental difference is the main factor in deciding which technology to use. However, there are many other design factors to consider, including transport protocols, host processes, security, performance, state management, and support for transactions.

  Transport protocols and host processes

Although the SOAP specification does not require HTTP as the transport protocol, the client can only access Web services implemented using the ASP. NET Web service through HTTP because it is the only transport protocol supported by ASP. The service is called through IIS and is executed in the worker process aspnet_wp.exe of ASP.

. NET Remoting gives you the flexibility to host remote objects in any type of application, including Windows Forms, managed Windows Services, console applications, or ASP. As mentioned earlier,. NET Remoting provides two transport channels--tcp and HTTP. Both channels can use sockets to provide communication between arbitrary send and receive processes.

It can also integrate the HTTP channel with IIS and the ASP. This is important because of the following points. First, it is the only way to automatically start the. NET Remoting endpoint when a client request arrives. The. NET Remoting pipeline does not include the Service Control Manager (SCM) of the DCOM type required to start the remote server. If you provide remote objects from any process, you need to ensure that those processes are running. You must also make sure that they are thread-safe, for example, that thread A cannot activate an object after threads B begins to close the process. If you provide remote objects from ASP, you can take advantage of the Aspnet_wp.exe worker process, which is both automatic and thread safe. Second, integration with IIS is the only way to ensure cross-process. NET Remoting calls, as described in the next section.

Both the ASP and. NET Remoting infrastructures are extensible. You can filter inbound and outbound messages, and control the generation of type marshaling and metadata in many ways. With. NET Remoting, you can also implement your own formatting programs and channels.

  Security

Because ASP. NET Web services rely on HTTP, they are integrated with the standard Internet security infrastructure. The security features of IIS provide strong support for standard HTTP authentication scenarios, including basic, brief, digital certificates, and even Microsoft. NET Passport. (You can also use Windows integrated authentication, but only for clients in a trusting domain.) One advantage of using an available HTTP authentication scheme is that you do not need to change the code in the Web service, and IIS performs validation before the ASP is called. The ASP also supports. NET Passport-based validation and other custom validation scenarios. ASP. NET supports access control based on the destination URL, and supports access control through integration with the. NET Code access Security (CAS) infrastructure. SSL can be used to ensure the security of communications.

Although these standard transport technologies are quite effective for ensuring Web services, they can only do so. In complex situations involving multiple WEB services in different trusting domains, a custom special solution has to be established. Microsoft and other companies are working to create a security specification that provides message-level security features based on the extensibility of SOAP messages. One of these specifications is the XML Web Service Security Language (ws-security), which defines the framework for message-level credential transfer, message integrity, and message secrecy.

As described in the previous section, the. NET Remoting pipeline generally does not guarantee the security of cross-process calls. Using ASP. NET Remoting Endpoints hosted in IIS can take advantage of all the security features available with the ASP, including support for secure wired communications using SSL. If you are using a TCP channel or an HTTP channel that is hosted in a process (instead of aspnet_wp.exe), you must perform your own authentication, authorization, and secrecy mechanisms.

Another security issue to focus on is the ability to execute code in an environment that is never fully trusted without changing the default security policy. The ASP. NET WEB Service Client Agent can work in these environments, but the. NET Remoting agent does not. To use a. NET Remoting proxy from an environment that is not fully trusted, special serialization permissions are required. By default, this permission does not grant code that is downloaded from the Intranet or the Internet. If you are using a. NET Remoting client in an environment that is not fully trusted, you need to change the default security policy for the code that is loaded from those zones. When you connect to a system from a client running in a sandbox (a Windows forms application that is downloaded below), the ASP. NET Web service is a simpler choice because you do not need to change the security policy.

  State management

By default, the ASP. NET Web Service model takes a stateless service structure; it is not instinctively related to multiple calls from the same user. In addition, each time the client calls the ASP. NET Web service, a new object is created to serve the request. When the method call is complete, the object is destroyed. To maintain the state between requests, you can use the same techniques that ASP. NET pages use (for example, Session and Application property bags), or you can implement a custom solution yourself.

. NET Remoting supports many state management options and may be related to or irrelevant to multiple calls from the same user, depending on the object lifecycle schema that you select. The SingleCall object is stateless (such as an object used to invoke an ASP. NET Web service), the Singleton object shares the state of all clients, and the client-activated object maintains state on a per-client basis (with all related upgradeability and reliability issues that it produces).

  Performance

In terms of raw performance, the. NET Remoting Pipeline provides the fastest possible communication when using the TCP channel and binary formatter. In almost all of the tests that we made comparing the relative performance of the ASP. NET Web service and. Remoting, the ASP. NET Remoting endpoint of a SOAP formatter that uses the HTTP or TCP channel is more performance-rich. 。 More interestingly, the ASP and. NET Remoting endpoints using binary formatters and HTTP channels are very similar in performance. (For more information, see Performance Comparison:net Remoting vs. asp. NET Web Services.) )

  Corporate Services

An ASP. NET Web Service or an object that is provided through the Remoting can use local transactions to coordinate the work against a single database. If you need to coordinate work based on multiple resources, you can use the transactions advertised by. NET Enterprise Services (also known as COM +) (DTC distributed transactions managed by the COM + pipeline). It is important to note, however, that both the ASP and. NET Remoting pipelines cannot propagate advertised transactions, so neither endpoint can inherit the advertised transaction through a cross-process invocation.

This is not necessarily a bad thing. In general, the advertised transaction is higher than the cost of local affairs, and it is more expensive to go through the process of propagating the published transaction. If you do need this functionality, a simple solution is to deploy a System.EnterpriseServices.ServicedComponent-derived class in the. NET Enterprise Services server application (for more information, see COM + Integration:how. NET Enterprise Services Can help you Build distributed applications). Cross-process calls to objects of this class will be processed using DCOM to ensure that the transactional environment is propagated correctly. The more difficult solution is to use the underlying API to manually propagate distributed transactions.

It is important to note that traditional distributed transaction models generally do not apply to loosely coupled Web services. A model that is based on a compensating transaction (that is, a transaction that undoes the work submitted by another firm) is more meaningful because its isolation constraints are not very restrictive. There is a common belief among Web service providers, including Microsoft, that the more flexible the transactional model is required for Web service space, the more work is done in that space. By waiting for the standard method of defining a Web service transaction, you can implement your own compensation schema using local or advertised transactions, as appropriate.

  Summary

Although both the. NET Remoting infrastructure and the ASP. Network WEB Services can communicate across processes, each design works for different users. The ASP. NET WEB Service provides a simple programming model and has a wide range of uses.. Remoting provides a more complex programming model with a much narrower scope. It's important to understand how these two technologies work and choose the right technology for your application. In either case, use IIS and the ASP. NET to manage the process life cycle and provide general security.

My use of remoting technology is also required for the project:

1. Remoteing is mainly used for C/s structure project.

2, will remoting use TCP communication, than the Web service is not a little more efficient, but a few times higher, or even dozens of times-fold, is worthy of being on the basis of DCOM and other developed technology. For distributed applications across geographies and even across provinces (WANs), the level of efficiency means the survival of software systems.

I said on the blog this three-layer structure, the intention is only in the. NET environment, using reflection technology, object-relational mapping and other techniques, write a bottom point of the assembly, easy to write a database access program. The Assembly is able to encapsulate commonly used database operations. This assembly should be available whether it is in remoting, Web service, or WCF. As we learn the data structure in the university textbook, we learn a kind of thought. If only a technology is simply limited, in the rapid development, will eventually be eliminated. We are all mortals, and we cannot master all the techniques. For your project needs, is the best!

Table respect, Source: http://kb.cnblogs.com/page/50681/

Why copy others, send to their own blog: worry about others to delete posts, in the future want to see can not find, whether there is no reason, so do it.

WCF, Net remoting, Web service concepts and differences

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.