The difference between the add Service References and the Add Web References in the VS Class library project

Source: Internet
Author: User

Original: The difference between add Service References and add Web References in the VS Class library project

Birth problems:

1. In the VS2005 era, the main feature of Add Web Reference (Add Web Service Reference) is the addition of a Web services reference. Based on the. NET Framework 2.0.

2. Since VS2008, in order to support the WCF Service Library on the. NET Framework version 3.0 or 3.5. Added the Add service Reference (added services reference) feature. However, add Web Reference (Add Web Service Reference) is retained for version-forward compatibility.

Differences in the generation of reference files (this paragraph is from an online review, for informational purposes only):

Add the same webservice in two ways, creating the difference between Reference.cs:
1. The main add-on has a process to get the service metadata that deserializes the session local class file. The structure is basically similar. contain files such as Wsdl\discovery.
This is also related to the core industry standards that WCF service supports for Web service. One of the features of WCF, after all, is the compatibility of Web service features.
2. Different places when the add Web Reference generated in the Reference.cs file contains a service proxy class, he is responsible for communicating with the Web service, which inherits a SOAP class, using the SOAP protocol, the SOAP simple Object Access protocol, based on the XML language. It also contains the methods defined in the Web service classes, and the associated asynchronous invocation methods and events. Adhere to the primary rules for. NET Web Service.
The client file Reference.cs generated by the 3.ADD Service Reference. I looked at it, and this also deserializes a local proxy class, very similar to the former. But in addition to the service class and some other classes and contractual interfaces related to it. One of the more important is a contract and a communication pipeline. This is primarily related to the programming model of the WCF framework and the anti-serialization session mechanism. Because WCF emphasizes the concept of contracts and the binding protocol, this directly determines the channel type of client and server communication. You can see it in this file as well. In addition, there are service requests and corresponding information. Follow the rules for the WCF Service framework.

Usage differences:

1.ADD Web Reference:

Constructing an instance Webreference1.service1 WEBS1 = new Webreference1.service1 () is not overloaded. When using instance WEBS1, you can pass WEBS1. URL to change the address of the reference. such as: WEBS1. URL = "Http://localhost:7280/Service1.asmx".

2.ADD Service Reference:

Constructs an instance webreference1.service1 WEBS1 = new Webreference1.service1 () provides an overloaded construction method , the default constructor method refers to the address of the <client> node the configuration address in <endpoint> can also be used servicereference1.service1soapclient WEBS2 = new Servicereference1.service1soapclient ("Service1Soap", "Http://localhost:7280/Service1.asmx") to specify the service address. you can no longer use WEBS2. URL = "Http://localhost:7280/Service1.asmx" To change the service address.

Summary of Usage area table:

Add Service reference can only specify the address of the server when the instance instance is constructed and cannot be changed dynamically. This allows you to check for errors at compile time to reduce run-time errors.

The difference between the add Service References and the Add Web References in the VS Class library project

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.