Ensurepass

QUESTION 151

You are creating a Windows Communication Foundation (WCF) service. You do not want to expose the internal implementation at the service layer. You need to expose the following class as a service named Arithmetic with an operation named Sum.

 

public class Calculator

 

{

 

public int Add(int x, int y)

 

{

 

}

 

}

 

Which code segment should you use?

 

A.

[ServiceContract(Namespace=”Arithmetic”)]

public class Calculator

{

[OperationContract(Action=”Sum”)]

public int Add(int x, int y)

{

…..

}

}

B.

[ServiceContract(ConfigurationName=”Arithmetic”)]

public class Calculator {

[OperationContract(Action=”Sum”)]

public int Add(int x, int y)

{

…..

}

}

C.

[ServiceContract(Name=”Arithmetic”)]

public class Calculator

{ [OperationContract(Name=”Sum”)]

public int Add(int x, int y)

{

….

}

}

D.

[ServiceContract(Name=”Arithmetic”)]

public class Calculator {

[OperationContract(ReplyAction=”Sum”)]

public int Add(int x, int y)

{

…..

}

}

 

Correct Answer: C

 

 

QUESTION 152

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

 

clip_image001

 

You need to ensure that RecordPayments can correctly deserialize into an Employee or a Customer object.

 

What should you do?

 

A.

Implement the IExtensibleDataObject interface in the Person class.

B.

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

[KnownType(typeof(Person))]

C.

Implement the IExtension<> interface in the Person class.

D.

Add the following KnownType attributes to the Person class.

[KnownType(typeof(Employee))]

[KnownType(typeof(Customer))]

 

Correct Answer: D

 

 

QUESTION 153

A Windows Communication Foundation (WCF) client communicates with a service. You created the client proxy by using Add Service Reference in Microsoft Visual Studio. You need to ensure that the client accepts responses of up to 5 MB in size. What should you change in the configuration file’?

 

A.

the value of the maxBufferPoolSize attribute to 5242880

B.

the value of the maxReceivedMessageSize attribute to 5242880

C.

the value of the maxBytesPerRead attribute to 5242880

D.

the value of the maxBufferSize attribute to 5242880

 

Correct Answer: B

 

 

QUESTION 154

You are developing a Windows Communication Foundation (WCF) service that does not operate on a duplex channel.

 

You find that operations do not start until all previous operations have finished. The service hosting code contains the following lines.

 

Dim service = New WarehouseService()

 

Dim hose = New ServiceHost(service)

 

You need to ensure that new operations do not wait for previous operations to finish.

 

Which attribute should you use to decorate the service?

 

A.

<ServiceBehavior(

InstanceContextMode:=InstanceContextMode.Single,

ConcurrencyMode:=ConcurrencyMode.Single) >

B.

<CallbackBehavior(

ConcurrencyMode:=ConcurrencyMode.Multiple)>

C.

<ServiceBehavior(

InstanceContextMode:=InstanceContextMode.Single,

ConcurrencyMode:=ConcurrencyMode.Reentrant)>

D.

<ServiceBehovior(

InstanceContextMode:=InstanceContextMode.Single,

ConcurrencyMode:=ConcurrencyMode.Multiple)>

 

Correct Answer: D

 

 

 

 

 

 

QUESTION 155

You develop a Windows Communication Foundation (WCF) service. Many client applications will consume the service.

 

You have the following requirements:

 

clip_image003You must enable client sessions on the service.

clip_image003[1]The service must support multi-threaded operations.

clip_image003[2]If a client application uses sessions, the lifetime of the service instance must be scoped to the lifetime of the session.

clip_image003[3]If a client application does not use sessions, the lifetime of the service must be scoped to the lifetime of a method cal.

 

You need to configure the service.

 

What should you do? (Each correct answer presents part of the solution. Choose three.)

 

A.

In the ServiceContract attribute, set the value of the InstanceContextMode property to InstanceContextMode.PerSession.

B.

In the ServiceContract attribute, set the value of the SessionMode property to SessionMode.Allowed.

C.

In the ServiceBehavior attribute, set the value of the InstanceContextMode property to InstanceContextMode. PerSession.

D.

In the ServiceContract attribute, set the value of the ConcurrencyMode property to ConcurrencyMode.Multiple

E.

In the ServiceBehavior attribute, set the value of the ConcurrencyMode property to ConcurrencyMode.Multiple

F.

In the ServiceBehavior attribute, set the value of the SessionMode property to SessionMode.Allowed.

 

Correct Answer: BCE

Explanation:

B (not F):

ServiceContractAttribute.SessionMode Property Gets or sets whether sessions are allowed, not allowed or required.

 

C (not A):

* ServiceBehaviorAttribute Class

ecifies the internal execution behavior of a service contract implementation.

* ServiceBehaviorAttribute.InstanceContextMode Property Gets or sets the value that indicates when new service objects are created. One of the InstanceContextMode values; the default value is PerSession.

 

E (not D):

ServiceBehaviorAttribute.ConcurrencyMode Property Gets or sets whether a service supports one thread, multiple threads, or reentrant calls.

 

Note:

Example:

[ServiceContract(

Namespace=”http://microsoft.wcf.documentation”,

SessionMode=SessionMode.Required

)]

 

[ServiceBehavior(

ConcurrencyMode=ConcurrencyMode.Single,

InstanceContextMode=InstanceContextMode.PerSession,

ReleaseServiceInstanceOnTransactionComplete=true

)]

 

 

QUESTION 156

You are building a client for a Windows Communication Foundation (WCF) service. You need to create a proxy to consume this service which class should you use?

 

A.

ChannelFactory <TChannel>

B.

ServiceHost

C.

ClientRuntime

D.

CommunicationObject

 

Correct Answer: A

 

 

QUESTION 157

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

 

<ServiceContract() >

 

Public Interface IPaymentService

 

<OperationContract() >

 

Sub RecordPayments(ByVal person As Person)

 

End Interface

 

Public Class Person

 

End Class

 

Public Class Employee Inherits Person

 

End Class

 

Public Class Customer Inherits Person

 

End Class

 

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(Of 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

 

 

QUESTION 158

A Windows Communication Foundation (WCF) solution uses the following contracts. (Line numbers are included for reference only.)

 

01 [ServiceContract(CallbackContract = typeof(INameService))]

 

02 public interface IGreetingService

 

03 {

 

04 [OperationContract]

 

05 string GetMessage();

 

06 }

 

07

 

08 [ServiceContract]

 

09 public interface INameService

 

10 {

 

11 [OperationContract]

 

12 string GetName();

 

13 }

 

When the client calls GetMessage on the service interface, the service calls GetName on the client callback. In the client, the class NameService implements the callback contract.

 

The client channel is created as follows:

 

22 In stanceContext callbackContext =

 

new InstanceContext(new NameService(“client”));

 

25 DuplexChannelFactory<IGreetingService> factory =

 

new DuplexChannelFactory<IGreetingService>(

 

typeof(NameService), binding, address);

 

26 IGreetingService greetingService = factory.CreateChannel();

 

You need to ensure that the service callback is processed by the instance of NameService.

 

What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

Change line 25 to the following code segment.

DuplexChannelFactory<IGreetingService> factory =

new DuplexChannelFactory<IGreetingService>(

callbackContext, binding, address);

B.

Change line 26 to the following code segment.

IGreetingService greetingService =

factory.CreateChannel(callbackContext);

C.

Add the following code segment after line 26.

callbackContext.IncomingChannels.Add((IDuplexChannel)greetingService);

D.

Add the following code segment after line 26.

callbackContext.OutgoingChannels.Add((IDuplexChannel)greetingService);

 

Correct Answer: AB

 

 

QUESTION 159

You are creating a Windows Communication Foundation (WCF) service that accepts messages from clients when they are started. The message is defined as follows:

 

<MessageContract()>

 

Public Class Agent

 

Public Property CodeName As String

 

Public Property SecretHandshake As String

 

End Class

 

You have the following requirements:

 

The CodeName property must be sent in clear text. The service must be able to verify that the property value was not changed after being sent by the client.

 

The SecretHandshake property must not be sent in clear text and must be readable by the service.

 

What should you do?

 

A.

Add a MessageBodyMember attribute to the CodeName property and set the ProtectionLevel to Sign.

Add a MessageBodyMember attribute to the SecretHandshake property and set the ProtectionLevel to EncryptAndSign.

B.

Add a DataProtectionPermission attribute to the each property and set the ProtectData property to True.

C.

Add an XmlText attribute to the CodeName property and set the DataType property to Signed.

Add a PasswordPropertyText attribute to the SecretHandshake property and set its value to True.

D.

Add an ImmutableObject attribute to the CodeName property and set its value property to True.

Add a Browsable attribute to the SecretHandshake property and set its value to False.

 

Correct Answer: B

 

 

QUESTION 160

You develop a Window Communication Foundation (WCF) service.

 

You have the following requirements:

 

clip_image003[4]Create a data contract to pass data between client applications and the service.

clip_image003[5]Create the data that is restricted and cannot pass between client applications and the service.

 

You need to implement the restricted data members.

 

Which member access modifier should you use?

 

A.

Protected

B.

Public

C.

Shared

D.

Private

 

Correct Answer: C

 

Instant Access to Download Latest Complete Collection of Microsoft 70-513 Real Exam

Try Microsoft 70-513 Free Demo