0

When you add a WCF service reference to a project In Visual Studio, Is there any difference between specifying the url http://domain/MyService.svc and http://url/MyService.svc?wsdl ? are there any particular differences in the case where the targeted service is in https or if the targeted service requires authentication ?

In the "Add Service Reference" Window if you click on the "Advanced ..." button, it falls on the "Reference Service " window and in the latter we find the checkbox "Reuse types in referenced assemblies". I would like to know the meaning of this check box. According to my tests, when this check box is selected, for each DataContract used by the service, Visual Studio will search a corresponding DataContract class in the assemblies referenced by the project, if it finds a class that corresponds then it will use it instead of creating a new DataContract class. When the checkbox is not checked, Visual Studio creates a new class for each DataContract used by the service. The ServiceContract interface and the proxy class are created in all cases (the checkbox is checked or not) . Is this really it ?

DadyFuji
  • 243
  • 1
  • 12

1 Answers1

0

To answer the questions:

Is there any difference between specifying the url http://domain/MyService.svc and http://url/MyService.svc?wsdl

No - if you don't specify the ?wsdl URL, the wizard will obtain the WSDL by appending ?wsdl to the URL to retrieve the wsdl.

"Reuse types in referenced assemblies". I would like to know the meaning of this check box

If you have access to the assemblies containing the classes used in the service (e.g. the DataContracts) and reference them from the client, then this check box allows you to reuse these types without creating new proxy types on the client.

If you really don't want to create the proxied service interfaces and data transfer classes on the client, then have a look at ChannelFactory. This way you won't need to add a service reference at all (but you will need the service's ServiceContract interfaces and the data transfer assemblies)

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Wait a minute, do you mean that if the checkbox is checked and my project reference the ServiceContract Interface, the interface will not be created ? And how about the proxy class (class that inherits from System.ServiceModel.ClientBase) ? – DadyFuji Oct 18 '13 at 15:30
  • No, I mean if you add a direct reference to the assemblies containing the `Service Contract` interface and the `DataContract` classes in your client project, that you can do away with the `Add Service Reference` step entirely (and e.g. avoid having to update service reference etc in future). You'll still need to tweak the clients `*.config` file (or do this programatically) – StuartLC Oct 18 '13 at 15:35