VS 2008 Add a service reference to a Web reference difference and contact

Source: Internet
Author: User
Tags soap wsdl

The following is the http://www.frankxulei.com/?p=156 "Lao Xu's blog" in the statement

(1) The function of the Add Web Reference (Add Web Service Reference) provided in VS2005 is mainly to add Web services references.
(2) VS2008 retains the Add Web Reference (Add Web Service Reference) also for version forward compatibility. Many projects are currently based on the. NET Framework 2.0.
(3) VS2008 support for the WCF Service Library on the. NET Framework version 3.0 or 3.5 after the upgrade. Added the Add service Reference (Add Services Reference) feature. Framework3.0 or 3.5 is available.

The project type that also exists for the Add service Reference, add Web Reference, is the Web service program. Includes Web service projects. The normal console type is no add Web Reference.
I carefully contrast the two ways to add the same WebService generated client file Reference.cs, there is a difference.
1. The main add reference has an access to service metadata, deserialization of the local class file process. This structure is basically similar. Contains files such as Wsdl/discovery.
This is also related to the core industry standards of the WCF Service Support Web service. After all, one of the features of WCF is compatibility with Web service features.
2. In different places, the Add Web Reference generates a Reference.cs file containing a service proxy class that communicates with the Web service, inherits a SOAP class, uses a SOAP protocol, a SOAP simple Object access Protocol, and is based on an XML language. It also includes methods defined in Web service classes, and asynchronous invocation methods and events associated with them. Follow the primary rules for the. NET Web Service.
3.ADD Service Reference generated client file Reference.cs. I looked, and this would also deserialize a local proxy class, very similar to the former. However, in addition to the service class and its related to some other class and contract interface. One of the more important is a contract and a communication pipeline. This main and WCF framework
is related to the programming model and the inverse sequence speech mechanism. Because WCF emphasizes the concept of contract and the binding protocol, this directly determines the channel type of communication between client and server. You can see it in this file, too. In addition, there are service requests and corresponding information. Follow the rules of the WCF Service framework.

=================================================================================

The following is transferred from http://www.cnblogs.com/wang_yb/archive/2010/04/28/1723332.html

It has long been found that there are two ways to apply Web Service in vs2008, the Add Web Reference and add Service Reference, but it's not always clear what the difference is. Take advantage of today's free time to experiment with the differences and record them for your reference.

First find on the internet, found that there are the following two major differences:

1.ADD Web Reference is generated by the Wsdl.exe client proxy.

The ADD Service reference is generated by the SvcUtil.exe client proxy.

2.ADD WEB Reference generated proxies can be invoked by the. net1.1 or. net2.0 clients

The Add service reference generated proxies can only be invoked by the. net3.0+ client, and the Add Service reference not only generates a proxy class, but also generates the corresponding tag in web.config.

First, create a solution, in which three additional works (a WebApplication, a webservice, a wcfservice).

1. Test Web Reference

(1.1) referencing WebService in WebApplication (ie webservicefortest)

After the reference can be used normally, web.config in the following configuration (port number on the URL and personal machine-related)

<applicationSettings>
<WebReferAndSvcRefer.Properties.Settings>
<setting name= "Webreferandsvcrefer_asmxwebrefer_service1"
serializeas= "String" >

<value>http://localhost:1253/service1.asmx "</value>
</setting>
</WebReferAndSvcRefer.Properties.Settings>
</applicationsettings

(1.2) referencing Wcfservice in WebApplication (ie wcfservicefortest)

after the reference is not working properly , the Web.config configuration is similar to the above

<applicationSettings>
<WebReferAndSvcRefer.Properties.Settings>
<setting name= "Webreferandsvcrefer_wcfwebrefer_service1"
serializeas= "String" >
<value>http://localhost:1254/Service1.svc</value>
</setting>
</WebReferAndSvcRefer.Properties.Settings>
</applicationSettings>

2. Test Service Reference

(2.1) referencing WebService in WebApplication (ie webservicefortest)

After the reference can be used normally, web.config in the following configuration (port number on the URL and personal machine-related)

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name= "Service1Soap" closetimeout= "00:01:00"
opentimeout= "00:01:00"
receivetimeout= "00:10:00" sendtimeout= "00:01:00"
Allowcookies= "false"
Bypassproxyonlocal= "false"
Hostnamecomparisonmode= "StrongWildcard"
Maxbuffersize= "65536" maxbufferpoolsize= "524288"
Maxreceivedmessagesize= "65536"
messageencoding= "Text" textencoding= "Utf-8"
Transfermode= "Buffered"
Usedefaultwebproxy= "true" >
<readerquotas maxdepth= "8192" maxstringcontentlength= "
Maxarraylength= "16384"
Maxbytesperread= "4096" maxnametablecharcount= "16384"/>
<security mode= "None" >
<transport clientcredentialtype= "None" proxycredentialtype= "None" realm= ""/>
<message clientcredentialtype= "UserName" algorithmsuite= "Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address= "Http://localhost:1253/Service1.asmx" binding= "BasicHttpBinding"
bindingconfiguration= "Service1Soap"
contract= "Asmxsvcrefer.service1soap" name= "Service1Soap"/>
</client>

</system.serviceModel>

(2.2) referencing Wcfservice in WebApplication (ie wcfservicefortest)

After the reference can be used normally, web.config in the following configuration (port number on the URL and personal machine-related)

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name= "Wshttpbinding_iservice1"
closetimeout= "00:01:00"
opentimeout= "00:01:00" receivetimeout= "00:10:00"
sendtimeout= "00:01:00"
Bypassproxyonlocal= "false" transactionflow= "false"
Hostnamecomparisonmode= "StrongWildcard"
Maxbufferpoolsize= "524288"
Maxreceivedmessagesize= "65536"
messageencoding= "Text" textencoding= "Utf-8"
Usedefaultwebproxy= "true"
Allowcookies= "false" >
<readerquotas maxdepth= "8192" maxstringcontentlength= "
Maxarraylength= "16384"
Maxbytesperread= "4096" maxnametablecharcount= "16384"/>
<reliablesession ordered= "true" inactivitytimeout= "00:10:00"
Enabled= "false"/>
<security mode= "Message" >
<transport clientcredentialtype= "Windows"
Proxycredentialtype= "None" realm= ""/>
<message clientcredentialtype= "Windows"
Negotiateservicecredential= "true"
Algorithmsuite= "Default" establishsecuritycontext= "true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address= "Http://localhost:1254/Service1.svc"
Binding= "Wshttpbinding"
bindingconfiguration= "Wshttpbinding_iservice1"
contract= "Wcfsvcrefer.iservice1"
Name= "Wshttpbinding_iservice1" >
<identity>
<dns value= "localhost"/>
</identity>
</endpoint>
</client>

</system.serviceModel>

3. Test client's. NET Framework Requirements

Drop the target framework for webapplication (that is, Webreferandsvcrefer) to 2.0

It was then found that the service Reference could not be referenced in Webreferandsvcrefer, proving that the agent generated by the add Service Reference could only be invoked by the. net3.0+ Client.

4. Summary

The above experimental process basically proves the two differences mentioned at the beginning of this article, in which (1.2) Add Web reference can not use WCF also proves that the Add Web The proxy generated by reference is a client of. net1.1 or. net2.0 (WCF need. net3.0 support).

==================================================================================

In this way, to say that the upward compatibility, in fact, is not really up-compatible, "service reference" should be more extensive scope, (if installed on the. net3.0 client), you should be able to call the webservice as a "service reference."
How to use a "service reference" in vs2008 to invoke a Web service.

If you want to invoke a Java-written WebService class Test.java)

(1) If you add a Web reference, VS will automatically generate a "class name +service" class to control the Java class, this example should be the Testservice class. Calling this class is equivalent to calling the test class in Java.

(2) Check if you are adding a service reference, VS will automatically generate a "class name +client" class to control the Java class, this example should be the Testcilent class. Calling this class is equivalent to calling the test class in Java.

The following is transferred from: http://topic.csdn.net/u/20100728/18/09a6be3c-64d7-43a6-885d-0ea7547c64d6.html

If the complex type in your project is a LINQ to SQL or ado.net Entity Framework entity,
"Web References", "service references", are no different.

WCF uses DataContract to serialize complex types, while WebService is XmlSerializer, as long as you specify [DataContract] (for type names) and [DataMember] (for attributes) for your complex type. Regenerate and run WebService,
You can then use the Add Service reference to generate the proxy class on the client.

Recommended use of "service references"


Reference:

VS 2008 Adding service references to Web references differences and relationships: http://hi.baidu.com/%BE%C5%CC%EC%D6%AE%B7%EF/blog/item/57d8961516dad515962b43a8.html

What is the difference between add Service References and add Web References in a VS2008 Class library project: http://social.microsoft.com/Forums/zh-CN/ Xmlwebserviceszhchs/thread/808d870b-49f1-47ac-b105-4beb580bcec6

The difference between adding a Web reference and adding a service reference: http://topic.csdn.net/u/20100728/18/09a6be3c-64d7-43a6-885d-0ea7547c64d6.html

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.