Latest MCTS 70-513 Dumps Real Exam Download 111-120

Ensurepass

QUESTION 111

You are developing a Windows Communication Foundation (WCF) service that contains the following service contract.

[ServiceContract()]public interface IPaymentService{

 [OperationContract()]void RecordPayments(Person person);}

public class Person

{ … }

public class Employee : Person

{ … }

public class Customer : Person

{ … }

You need to ensure that RecordPayments can correctly deserialize into an Employee or a Customer object. What should you do?

 

A. Add the following KnownType attribute to the Employee class and to the Customer class.

[KnownType(GetType(Person))]

B. Implement the IExtensibleDataObject interface in the Person class.

C. Implement the IExtension(ofType(T))interface in the Person class.

D. Add the following KnownType attributes to the Person class.

[KnownType(GetType(Employee))]

[KnownType(GetType(Customer))]

 

Correct Answer: D

Explanation/Reference:Data Contract Known Types

(http://msdn.microsoft.com/en-us/library/ms730167.aspx)

The KnownTypeAttribute class allows you to specify, in advance, the types that should be included for consideration during deserialization.

 

 

QUESTION 112

You are developing a Windows Communication Foundation (WCF) service to replace an existing ASMX Web service. The WCF service contains the following code segment. (Line numbers are included for reference only.)

01 [ServiceContract()]

02

03 public interface IEmployeeService

04 {

05 [OperationContract()]

06 EmployeeInfo GetEmployeeInfo(int employeeID);

07

08 }

09

10 public class EmployeeService : IEmployeeService

11 {

12

13 public EmployeeInfo GetEmployeeInfo(int employeeID)

14 15  {   

16 17 18  }  } 

19 

20 public class EmployeeInfo

21 {

22 …

23 public int EmployeeID { get; set; }

24 public string FirstName { get; set; }

25 public string LastName { get; set; }

26

27 }

The existing Web service returns the EmployeelD as an attribute of the Employeelnfo element in the response XML. You need to ensure that applications can consume the service without code changes in the client. What should you do?

 

A. Insert the following code at line 02.

[DataContractFormat()]

Insert the following code at line 22.

[DataMember()]

B. Insert the following code at line 02.

[XmlSerializerFormat()]

Insert the following code at line 22.

[XmlAtttibute()]

C. Insert the following code at line 09.

[XmlSerializerFormat()]

Insert the following code at line 22.

[XmlAttribute()]

D. Insert the following code at line 19.

[DataContractFormat()]

Insert the following code at line 22.

[DataMember()]

 

Correct Answer: B

Explanation/Reference:DataContractFormatAttribute Class

(http://msdn.microsoft.com/en-us/library/system.servicemodel.datacontractformatattribute.aspx)

Why not A???

 

 

QUESTION 113

You are developing a Windows Communication Foundation (WCF) service to provide an in-memory cache. The following code is part of your solution. (Line numbers are included for reference only.)

01

02 public interface IInMemoryCacheService

03 {

04 [OperationContract()]

05 string GetCachedItem(string key);

06

07 [OperationContract()]

08 void CacheItem(string key, string item);

09

10 }

11

12 [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

13 public class CacheService : IInMemoryCacheService

14 {

15

16 Hashtable cache = new Hashtable();

17

18 public string GetCachedItem(string key)

19 {

20 return cache(key).ToString();

21 }

22

23 public void CacheItem(string key, string item)

24 {

25 if (cache.Contains(key))

26 cache.Remove(key);

27 cache.Add(key, item);

28 }

29 }

Users report that the cache is getting updated with cache changes of other users.

You need to ensure that each user’s cache is maintained and isolated from other users.

Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

clip_image002

 

Correct Answer: BD

Explanation/Reference:InstanceContextMode enumeration

(http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx)

PerSession A new InstanceContext object is created for each session. PerCall A new InstanceContext object is created prior to and recycled subsequent to each call. If the channel does not create a session this value behaves as if it were PerCall. Single Only one InstanceContext object is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created.

 

 

QUESTION 114

A Windows Communication Foundation (WCF) service is hosted in Microsoft Internet Information Services (IIS).

You are preparing the configuration file for production deployment. You need to set up tracing so that an administrator can adjust

the System.ServiceModel trace level without causing the ASP.NET host application domain to restart.

You need to ensure that tracing is turned off by default. What should you do?

 

A. Add the following element to the system.serviceModel configuration section:

<diagnostics wmiProviderEnabled=”true” />

Add the following element to the system.diagnostics configuration section:

<sources>

 <source name=”System.ServiceModel” switchValue=”Off”>

<listeners>

 <add initializeData=”app_tracelog.svclog”

type=”System.Diagnostics.XmlWriterTraceListener”

name=”ServiceModelTraceListener”

 traceOutputOptions=”Timestamp”/>

</listeners>

</source>

</sources>

B. Add the following element to the system.serviceModel configuration section:

<diagnostics etwProviderId=”{7799e76e-0f8b-407a-a616-3f91ba6072b9}”>

Add the following element to the system.diagnostics configuration section:

<sources>

 <source name=”System.ServiceModel” switchValue=”Off”>

<listeners>

 <add initializeData=”app_tracelog.svclog”

type=”System.Diagnostics.XmlWriterTraceListener”

name=”ServiceModelTraceListener”

 traceOutputOptions=”Timestamp”/>

</listeners>

</source>

</sources>

C. Add the following element to the system.serviceModel configuration section:

<serviceBehaviors>

 <behavior>

 <serviceDebug/>

</behavior>

</serviceBehaviors>

Add the following element to the system.diagnostics configuration section:

<sources>

 <source name=”System.ServiceModel” switchValue=”ActivityTracing”>

<listeners>

 <add initializeData=”app_tracelog.svclog”

type=”System.Diagnostics.XmlWriterTraceListener”

name=”ServiceModelTraceListener”

 traceOutputOptions=”Timestamp”/>

</listeners>

</source>

</sources>

D. Add the following element to the system.serviceModel configuration section:

<serviceBehaviors>

 <behavior>

 <serviceDebug/>

</behavior>

</serviceBehaviors>

Add the following element to the system.diagnostics configuration section:

<sources>

 <source name=”System.ServiceModel” switchValue=”Off”>

<listeners>

 <add initializeData=”app_tracelog.svclog”

type=”System.Diagnostics.XmlWriterTraceListener”

name=”ServiceModelTraceListener”

 traceOutputOptions=”Timestamp”/>

</listeners>

</source>

</sources>

 

Correct Answer: A

Explanation/Reference:Enabling WMI

A WMI provider is a component that exposes instrumentation at runtime through a WBEM-compatible interface.

It consists of a set of WMI objects that have attribute/value pairs. Pairs can be of a number of simple types.

Management tools can connect to the services through the interface at runtime.

WCF exposes attributes of services such as addresses, bindings, behaviors, and listeners.

The built-in WMI provider can be activated in the configuration file of the application.

This is done through the wmiProviderEnabled attribute of the <diagnostics> Element in the system.ServiceModel element section,

as shown in the following sample configuration.

<system.serviceModel> … <diagnostics wmiProviderEnabled=”true” /> …

</system.serviceModel>

This configuration entry exposes a WMI interface. Management applications can now connect through this interface and access the management instrumentation of the application.

Using Windows Management Instrumentation for Diagnostics

(http://msdn.microsoft.com/en-us/library/ms735120(v=vs.90).aspx)

 

 

QUESTION 115

A client application calls a Windows Communication Foundation (WCF) service with a proxy class that was generated by Visual Studio.

The service binding was changed from wsHttpBinding to basicHttpBinding. The method signatures in the service contract are changed.

After these changes, the client application receives errors when calling methods on the service.

You need to ensure that the client can invoke methods on the service successfully. What should you do?

 

A. Update the configuration file to use basicHttpBinding.

B. Enable anonymous authentication for the service.

C. Copy the configuration file elements under the <system.serviceModel> element from the service back to the client.

D. Update the service reference.

 

Correct Answer: D

Explanation/Reference:

 

 

QUESTION 116

You are configuring services to be discoverable. The services must be discoverable without relying on a central server.

Client applications that consume the services are on a network segment that is separate from the network segment that the services are located on.

A firewall blocks all TCP ports between the two network segments, but allows other protocols to pass through.

You need to ensure that the client applications can discover the services. What should you do?

 

A. Use ad-hoc discovery mode over HTTP.

B. Use ad-hoc discovery mode over UDP.

C. Use managed discovery mode over HTTP.

D. Use managed discovery mode over UDP.

 

Correct Answer: B

Explanation/Reference:Ad-Hoc and Managed Modes

The Discovery API supports two different modes: Managed and Ad-Hoc. In Managed mode there is a centralized server

called a discovery proxy that maintains information about available services. The discovery proxy can be populated with

information about services in a variety of ways. For example, services can send announcement messages during start up

to the discovery proxy or the proxy may read data from a database or a configuration file to determine what services are available.

How the discovery proxy is populated is completely up to the developer. Clients use the discovery proxy to retrieve information about available services.

When a client searches for a service it sends a Probe message to the discovery proxy and the proxy determines whether any

of the services it knows about match the service the client is searching for. If there are matches the discovery proxy sends a ProbeMatch

response back to the client. The client can then contact the service directly using the service information returned from the proxy.

The key principle behind Managed mode is that the discovery requests are sent in a unicast manner to one authority, the discovery proxy.

The .NET Framework contains key components that allow you to build your own proxy. Clients and services can locate the proxy by multiple methods:

The proxy can respond to ad-hoc messages.

The proxy can send an announcement message during start up.

Clients and services can be written to look for a specific well-known endpoint.

In Ad-Hoc mode, there is no centralized server. All discovery messages such as service announcements and client requests

are sent in a multicast fashion. By default the .NET Framework contains support for Ad-Hoc discovery over the UDP protocol.

For example, if a service is configured to send out a Hello announcement on start up, it sends it out over a well-known,

multicast address using the UDP protocol. Clients have to actively listen for these announcements and process them accordingly.

When a client sends a Probe message for a service it is sent over the network using a multicast protocol. Each service that receives

the request determines whether it matches the criteria in the Probe message and responds directly to the client with a ProbeMatch message

if the service matches the criteria specified in the Probe message.

WCF Discovery Overview

(http://msdn.microsoft.com/en-us/library/dd456791.aspx)

 

 

QUESTION 117

You are developing a Windows Communication Foundation (WCF) client application. The client application contains the following code.

[ServiceContract]public interface ISocialStatus{

 [OperationContract]

[WebInvoke(UriTemplate = “/statuses/update.xml?status-{text}”)]

void UpdateStatus(string text);

}public class SocialClient : ClientBase<ISocialStatus>, ISocialStatus{

 … }

The configuration file contains the following lines.

<system.serviceModel><client>

 <endpoint name=”SocialClient” address=”http://contoso.com”

binding=”webHttpBinding” contract=”SocialApp.ISocialStatus”

bindingConfiguration=”BindingConfig” />

</client><bindings /></system.serviceModel>

You need to ensure that the service is consumed. Which code segment should you use?

 

A.            var client = new SocialClient(“SocialClient”);client.Endpoint.Behaviors.Add(new WebHttpBehavior());

B.            var client = new SocialClient(“SocialClient”);client.Endpoint.Behaviors.Add(new WebScriptEnablingBehovior());

C.            var client = new SocialClient(“POST”);client.Endpoint.Behaviors.Add(new WebHttpBehovior());

D.            var client = new SocialClient(“POST”);client.Endpoint.Behaviors.Add(new WebScriptEnablingBehavior());

 

Correct Answer: A

Explanation/Reference:ClientBase<TChannel> Class

(http://msdn.microsoft.com/en-us/library/ms576141.aspx)

ClientBase<TChannel> Class

Provides the base implementation used to create client objects that can call services.

Example:

public partial class SampleServiceClient : System.ServiceModel.ClientBase<ISampleService>, ISampleService {

 public SampleServiceClient()

 {

 }

 public SampleServiceClient(string endpointConfigurationName) :

base(endpointConfigurationName)

 {

 }

 public SampleServiceClient(string endpointConfigurationName, string remoteAddress) :

base(endpointConfigurationName, remoteAddress)

 {

 }

 public SampleServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :

base(endpointConfigurationName, remoteAddress)

 {

 }

    public SampleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :

base(binding, remoteAddress)

 {

 }

 public string SampleMethod(string msg) { return base.Channel.SampleMethod(msg); } }

 

 

QUESTION 118

You are developing a new version of an existing message contract named CustomerDetailsVersion1.

The new version of the message contract must add a Department field of type String to the SOAP header.

You create a new class named CustomerDetailsVersion2 that inherits from CustomerDetailsVersion1.

You need to ensure that all client applications can consume the service. Which code segment should you use?

 

A.            [MessageContract]public class CustomerDetailsVersion2 : CustomerDetailsVersion1{

[MessageHeader(MustUnderstand = false)]

public string Department;

}

B.            public class CustomerDetailsVersion2 : CustomerDetailsVersion1

{

[MessageHeader(MustUnderstand = false)]

public string Department;

}

C.            [MessageContract]public class CustomerDetailsVersion2 : CustomerDetailsVersion1{

[MessageHeader(MustUnderstand = true)]

public string Department;

}

D.            public class CustomerDetailsVersion2 : CustomerDetailsVersion1

{

[MessageHeader(MustUnderstand = true)]

public string Department;

}

 

Correct Answer: A

Explanation/Reference:SoapHeader.MustUnderstand Property

Gets or sets a value indicating whether the SoapHeader must be understood.

true if the XML Web service must properly interpret and process the SoapHeader; otherwise, false. The default is false.

When an XML Web service client adds a SOAP header to an XML Web service method call with the MustUnderstand property set to true,

the XML Web service method must set the DidUnderstand property to true;

otherwise, a SoapHeaderException is thrown back to the XML Web service client by ASP.NET.

Although both the EncodedMustUnderstand and MustUnderstand properties can be used to set the value of the

mustUnderstand attribute within the SOAP header, the MustUnderstand property allows you to set the attribute using a Boolean value.

Data Contract Versioning

(http://msdn.microsoft.com/en-us/library/ms731138%28v=VS.100%29.aspx)

Best Practices: Data Contract Versioning

(http://msdn.microsoft.com/en-us/library/ms733832.aspx)

 

 

QUESTION 119

You are developing a Windows Communication Foundation (WCF) service.

You establish that the largest size of valid messages is 8,000 bytes. You notice that many malformed messages are being transmitted.

Detailed information about whether each message is malformed must be logged.

You need to ensure that this information is saved in XML format so that it can be easily analyzed.

What should you add to the service configuration file?

 

clip_image004

 

Correct Answer: D

Explanation/Reference:Configuring Message Logging

(http://msdn.microsoft.com/en-us/library/ms730064.aspx)

logMalformedMessages=”true” is a key attribute

 

 

QUESTION 120

You are developing a Windows Communication Foundation (WCF) service that must be discoverable.

You need to ensure that the ServiceHost instance supports multiple discovery versions. What should you do?

 

A. – Specify a unique DiscoveryVersion parameter for each endpoint constructor.

-Use the same value for the Address property of each endpoint.

B. – Use the endpoint constructor without the DiscoveryVersion parameter.

-Use a unique value for the Address property of each endpoint.

C. – Specify a unique DiscoveryVersion parameter for each endpoint constructor.

-Use a unique value for the Address property of each endpoint.

D. – Use the endpoint constructor without the DiscoveryVersion parameter.

-Use the same value for the Address property of each endpoint.

 

Correct Answer: C

Explanation/Reference:

Supporting Multiple UDP Discovery Endpoints for Different Discovery Versions on a Single Service Host

You may want to expose multiple UDP Discovery Endpoints for different discovery versions on a single service host.

To do this you must specify a unique address for each UDP discovery endpoint. The following example shows how to do this.

UdpDiscoveryEndpoint newVersionUdpEndpoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscovery11);UdpDiscoveryEndpoint oldVersionUdpEndpoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);

newVersionUdpEndpoint.Address = new EndpointAddress(newVersionUdpEndpoint.Address.Uri.ToString() + “/version11”);oldVersionUdpEndpoint.Address = new EndpointAddress(oldVersionUdpEndpoint.Address.Uri.ToString() + “/versionAril2005”);

serviceHost.AddServiceEndpoint(newVersionUdpEndpoint);serviceHost.AddServiceEndpoint(oldVersionUdpEndpoint);

Discovery Versioning

(http://msdn.microsoft.com/en-us/library/dd456799.aspx)

 

Download Latest MCTS 70-513 Real Free Tests , help you to pass exam 100%.