AddWebAndServiceReferenceI was playing around with building a simple WCF ASP.NET client in Visual Studio 2008 and wanted to make a reference to my WCF service (that used basicHttpBinding). I have built plenty of ASMX web services in the past so simply selected “Add Web Reference” as I’d done before, pointed to my .svc file hosted in IIS, and away I went – everything worked as expected.
Then I spied the “Add Service Reference” menu option and thought – hey that’s weird I wonder what that does?
Well it’s pretty simple really.
Add Web Reference is a wrapper over wsdl.exe and can be used to create proxies for .NET 1.1 or 2.0 clients. Of course this means when you are pointing to a WCF service you have to be pointing to an endpoint that uses basicHttpBinding (as I was).
Add Service Reference is a wrapper over svcutil.exe and also creates clients proxies (and additionally web.config entries). These proxies, however, can only be consumed by .NET 3.0+ clients.
It seems to me that a better approach would have been to have a single menu option that allowed you to select the proposed target framework.






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

powered by



Difference between WCF Service Reference and Web Reference

Tuesday, July 1, 2008

Previously, I wrote a post about Adding Service Reference in VS 2008. Adding Web Reference has been deprecated in VS 2008, as Microsoft now wants to promote WCF's Add Service Reference only. In this post we'll see basic differences in client proxy which have implemented Add Web Reference ( AWR ) and Add Service Reference ( ASR )

First difference is that to create AWR resources (proxy class and config) in WCF client you use wsdl.exe, whereas for ASR you use svcutil.exe

Now Imagine you have ASMX service

http://www.blogger.com/post-edit.g?blogID=2403430606101974989&postID=2436002957902424313#

whose reference you added onto a WCF client using AWR. So its app.config will look like the one below



<Consoleapp.Properties.Settings>
    <setting name="ConsoleApp_MySvc_MyService" serializeAs="String">
   <value>http://localhost/WCFWeb/MyService.asmx</value>
    </setting>
    </Consoleapp>



Now if you Add Service Reference of the same ASMX service on the same client, the app.config will look something like this



<endpoint address="http://localhost/WCFWeb/MyService.asmx"
    binding="basicHttpBinding" bindingConfiguration="ServiceSoap"
    contract="ASMXRef.ServiceSoap" name="ServiceSoap"/>
    <binding name="ServiceSoap" 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="32" maxStringContentLength="8192"
    maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"
    />
    <security mode="None">
    <transport clientCredentialType="None" proxyCredentialType="None"
    realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
    </binding>




So you can clearly note how ASR register additional level of detail like Bindings, Commincation parameters, transport security and message security info. Whereas AWR just registers a app.config key. This is difference between ASR and AWR from configuration information point.