What should you do?

You develop a Windows Communication Foundation (WCF) service. You name the service MovieService in the Movie namespace.
The service is hosted in Microsoft Internet Information Services (IIS). You copy the assembly containing the service to the bin folder in the virtual directory path.
You need to set up the URI that is mapped to the service. What should you do?

You develop a Windows Communication Foundation (WCF) service. You name the service MovieService in the Movie namespace.
The service is hosted in Microsoft Internet Information Services (IIS). You copy the assembly containing the service to the bin folder in the virtual directory path.
You need to set up the URI that is mapped to the service. What should you do?

A.
Add the following code segment to the web.config file.
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress=”./Movie” service=”Movie.MovieService” />
</serviceActivations>
</serviceHostingEnvironment>

B.
Add a Movie.svc file in the root of the virtual path with the following line.
<% @ServiceHost language=”C#” Service=”MovieService”>

C.
Add the following code segment to the web.config file.
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress=”./Movie.svc” service=”Movie.MovieService” />
</serviceActivations>
</serviceHostingEnvirornnent>

D.
Add a Movie.svc file in the root of the virtual path with the following line.
<% @ServiceHost language=”C#” Service=”MovieService.svc” %>

Explanation:
@ServiceHost
(http://msdn.microsoft.com/en-us/library/aa967286.aspx)

<% @ServiceHost
Service = “Service, ServiceNamespace”
Factory = “Factory, FactoryNamespace”
Debug = “Debug”
Language = “Language”
CodeBehind = “CodeBehind”%>

Service
The CLR type name of the service hosted. This should be a qualified name of a type that implements one or more of the service contacts.

Factory
The CLR type name of the service host factory used to instantiate the service host. This attribute is optional.
If unspecified, the default ServiceHostFactory is used, which returns an instance of ServiceHost.

Debug
Indicates whether the Windows Communication Foundation (WCF) service should be compiled with debug symbols.
true if the WCF service should be compiled with debug symbols; otherwise, false.

Language
Specifies the language used when compiling all the inline code within file (.svc). The values can represent any .NET-supported language,
including C#, VB, and JS, which refer to C#, Visual Basic .NET, and JScript .NET, respectively. This attribute is optional.

CodeBehind
Specifies the source file that implements the XML Web service, when the class that implements the XML Web service
does not reside in the same file and has not been compiled into an assembly and placed in the \Bin directory.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Martin

Martin

Answer B is a syntax error. Correct answer is D. The explanation proves it.

valenburm

valenburm

Answer D is wrong, because Service must be the CLR type name of the service hosted and not the file name.

valenburm

valenburm

B or C are correct answer. C allows you to create a service without the need to
specify the .svc file.

John Galt

John Galt

It’s clearly either B or C. (A is incorrect because you need ‘.svc’ after Movie, and D is incorrect, because you don’t need ‘.svc’ after Movie. Now the real question is if it’s B or C. I spent a lot of time researching this, and am now convinced the actual answer is B not C.

Here’s my reasoning. Check out the following link:
http://msdn.microsoft.com/en-us/library/ee358764%28v=vs.110%29.aspx

You can see the following note at the bottom there:
– The relativeAddress attribute must be set to a relative address such as “/service.svc” or “~/<sub-directory/service.svc”.

I then looked at a bunch of example online, and I never saw relativeAQddress="./ServiceName.svc" used. There was never an example with a dot in front of it.

Bottom line – the answer is B.