Latest MCTS 70-513 Dumps Real Exam Download 11-20

Ensurepass

QUESTION 11

A Windows Communication Foundation (WCF) service implements a contract with one-way and request-reply operations.

The service is exposed over a TCP transport. Clients use a router to communicate with the service.

The router is implemented as follows. (Line numbers are included for reference only.)

01 ServiceHost host = new ServiceHost(typeof(RoutingService));

02 host.AddServiceEndpoint(

03 typeof(ISimplexDatagramRouter),

04 new NetTcpBinding(), “net.tcp://localhost/Router”

05 );

06 List<ServiceEndpoint> lep = new List<ServiceEndpoint>();

07 lep.Add(

08 new ServiceEndpoint(

09 ContractDescription.GetContract(

10 typeof(ISimplexDatagramRouter)

11 ),

12 new NetTcpBinding(),

13 new EndpointAddress(“net.tcp://localhost:8080/Logger”)

14 )

15 );

16 RoutingConfiguration rc = new RoutingConfiguration();

17 rc.FilterTable.Add(new MatchAllMessageFilter(), lep);

18 host.Description.Behaviors.Add(new RoutingBehavior(rc));

Request-reply operations are failing. You need to ensure that the router can handle one-way and request-reply operations. What should you do?

 

A. Change line 03 as follows:

typeof(IRequestReplyRouter),

B. Change line 03 as follows:

typeof(IDuplexSessionRouter),

C. Change line 10 as follows:

typeof(IRequestReplyRouter)

D. Change line 10 as follows:

typeof(IDuplexSessionRouter)

 

Correct Answer: B

Explanation/Reference:

IDuplexSessionRouter Interface Defines the interface required to process messages from duplex session channels.

IDuplexSessionRouter Interface

(http://msdn.microsoft.com/en-us/library/system.servicemodel.routing.iduplexsessionrouter(v=vs.110).aspx)

 

 

QUESTION 12

You are modifying an existing Windows Communication Foundation (WCF) service that is defined as follows:

[ServiceContract]public interface IMessageProcessor{

 [OperationContract]

void ProcessMessages();}public class MessageProcessor: IMessageProcessor{

 public void ProcessMessage();SubmitOrder();}

SubmitOrder makes a call to another service. The ProcessMessage method does not perform as expected under a heavy load.

You need to enable processing of multiple messages. New messages must only be processed when the ProcessMessage method is not processing requests,

or when it is waiting for calls to SubmitOrder to return.

Which attribute should you apply to the MessageProcessor class?

 

A. CallbackBehavior(ConcurrencyMode=ConcurencyMode.Reentrant)

B. CallbackBehavior(ConcurrencyMode=ConcurrencyMode.Multiple)

C. ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Reentrant)

D. ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Multiple)

 

Correct Answer: C

Explanation/Reference:

ConcurrencyMode.Reentrant implies that the service (or callback) processes only one message at a given time (analogous to ConcurencyMode.Single).

To ensure thread safety, Windows Communication Foundation (WCF) locks the InstanceContext processing a message so that no other messages can be processed.

In case of Reentrant mode, the InstanceContext is unlocked just before the service makes an outgoing call thereby allowing the subsequent call,

(which can be reentrant as demonstrated in the sample) to get the lock next time it comes in to the service.

ConcurrencyMode Enumeration

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

 

 

QUESTION 13

clip_image002

A. In the client configuration, change the value of the address attribute to

net.tcp://www.contoso.com/MyService

B. In the client configuration, change the value of the address attribute to net.tcp://www.contoso.com/MyService listen=http://www.contoso.com/MyService.

C. After instantiating the client and before invoking any service operation, add this line of code.

EndpointBehaviors.Add(new EndpointDiscoveryBehavior(){ Enabled = true });

D. After instantiating the client and before invoking any service operation, add this line of code. client.Endpoint.Behaviors.Add(new ClientViaBehavior(new Uri(“net.tcp://www.contoso.com/IMyService”)));

 

Correct Answer: D

Explanation/Reference:

The ClientViaBehavior is used by clients to specify the URI for which the transport channel should be created.

If such a behavior exists in the behavior collection on a client endpoint, the transport uses the URI that it provides,

while all the other channel layers in the stack use the EndpointAddress provided at ChannelFactory construction time.

This EndpointAddress also becomes the WS-Addressing To header.

Use this behavior when the immediate network destination is not the intended processor of the message to enable multiple-hop

conversations when the calling application does not necessarily know the ultimate destination or when the destination Via header is not an address.

You can also set this value using the <clientVia> element in a client application configuration file.

ClientViaBehavior Class

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

 

 

QUESTION 14

A Windows Communication Foundation (WCF) service is self-hosted in a console application.

The service implements the IDataAccess contract, which is defined in the MyApplication namespace.

The service is implemented in a class named DataAccessService which implements the IDataAccess

interface and also is defined in the MyApplication namespace. The hosting code is as follows.

(Line numbers are included for reference only.)

01 static void Main(string[] args)

02 {

03 ServiceHost host;

04 …

05 host.Open();

06 Console.ReadLine();

07 host.Close();

08 }

You need to create a ServiceHost instance and assign it to the host variable. You also need to instantiate the service host. Which line of code should you insert at line 04?

 

A.            host = new ServiceHost(“MyApplication.DataAccessService”);

B.            host = new ServiceHost(“MyApplication.DataAccess”);

C.            host = new ServiceHost(typeof(IDataAccess));

D.            host = new ServiceHost(typeof(DataAccessService));

 

Correct Answer: D

Explanation/Reference:

Constructors

 ServiceHost() Initializes a new instance of the ServiceHost class.

 ServiceHost(Object, Uri[]) Initializes a new instance of the ServiceHost class with the instance of the service and its base addresses specified.

 ServiceHost(Type, Uri[]) Initializes a new instance of the ServiceHost class with the type of service and its base addresses specified.

ServiceHost Class

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

 

 

QUESTION 15

A Windows Communication Foundation (WCF) service implements the following contract.

[ServiceContract]public interface IHelloService{

 [OperationContract(WebGet(UriTemplate=”hello?name={name}”))]string SayHello(string name);}

The implementation is as follows:

public class HelloService: IHelloService

{ public string SayHello(string name){

return “Hello ” + name;}}

The service is self-hosted, and the hosting code is as follows:

WebServiceHost svcHost = CreateHost();

svcHost.Open();

Console.ReadLine();

svcHost.Close();

You need to implement CreateHost so that the service has a single endpoint hosted at http://localhost:8000/HelloService. Which code segment should you use?

 

A.            WebServiceHost svcHost = new WebServiceHost(typeof(HelloService));

svcHost.AddServiceEndpoint(typeof(IHelloService),

new WebHttpBinding(WebHttpSecurityMode.None),

“http://localhost:8000/HelloService”);

return svcHost;

B.            Uri baseAddress = new Uri(“http://localhost:8000”);WebServiceHost svcHost = new WebServiceHost(typeof(HelloService), baseAddress);svcHost.AddServiceEndpoint(typeof(IHelloService),

new WebHttpBinding(WebHttpSecurityMode.None),

“HelloService”);

return svcHost;

C.            WebServiceHost svcHost = new WebServiceHost(new HelloService());

svcHost.AddServiceEndpoint(typeof(IHelloService),

new WebHttpBinding(WebHttpSecurityMode.None),

“http://localhost:8000/HelloService”);

retumn svcHost

D.            Uri baseAddress = new Uri(“http://localhost:8000/”);WebServiceHost svcHost = new WebServiceHost(new HelloService(), baseAddress);svcHost.AddServiceEndpoint(typeof(IHelloService),

new WebHttpBinding(WebHttpSecurityMode.None),

“HelloService”);

retumn svcHost;

 

Correct Answer: B

Explanation/Reference:WebServiceHost Class

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

Name Description

Initializes a new instance of the WebServiceHost class.

WebServiceHost() Initializes a new instance of the WebServiceHost class with the specified singleton WebServiceHost server instance and base address.

(Object, Uri[]) Initializes a new instance of the WebServiceHost class with the specified service WebServiceHost type and base address.

(Type, Uri[])

WebServiceHost.AddServiceEndpoint() Method :

Name Description

Adds the specified service endpoint to the hosted service. (Inherited fromAddServiceEndpoint ServiceHostBase.)

(ServiceEndpoint)

AddServiceEndpoint Adds a service endpoint to the hosted service with a specified contract, binding,

(String, Binding, and endpoint address. (Inherited from ServiceHostBase.)

String)

Adds a service endpoint to the hosted service with a specified contract, binding,AddServiceEndpoint and a URI that contains the endpoint address. (Inherited from ServiceHostBase.)

(String, Binding, Uri) Adds a service endpoint to the hosted service with a specified contract, binding,AddServiceEndpoint and endpoint address. (Inherited from ServiceHost.)

(Type, Binding, String) Adds a service endpoint to the hosted service with a specified contract, binding,AddServiceEndpoint and URI that contains the endpoint address. (Inherited from ServiceHost.)

(Type, Binding, Uri) Adds a service endpoint to the hosted service with a specified contract, binding,AddServiceEndpoint endpoint address and URI that contains the address at which it listens. (Inherited(String, Binding, from ServiceHostBase.)

String, Uri) Adds a service endpoint to the hosted service with the specified contract,AddServiceEndpoint binding, and URIs that contain the endpoint and listening addresses. (Inherited(String, Binding, Uri, from ServiceHostBase.)

Uri)

AddServiceEndpoint Adds a service endpoint to the hosted service with a specified contract, binding, an endpoint address, and a URI on which the service listens. (Inherited from(Type, Binding, String, ServiceHost.)

Uri)

AddServiceEndpoint Adds a service endpoint to the hosted service with a specified contract, binding,

(Type, Binding, Uri, a URI that contains the endpoint address, and a URI on which the service listens.

Uri) (Inherited from ServiceHost.)

WebserviceHost doesn’t have a single param constructor.

public ServiceEndpoint AddServiceEndpoint( Type implementedContract, Binding binding, string address

)

Example: static void Main(string[] args) { Uri baseAddress = new Uri(“http://localhost:8000/”);

 WebServiceHost svcHost = new WebServiceHost(typeof(CalcService), baseAddress);

 try

 {

 svcHost.Open();

 Console.WriteLine(“Service is running”);

 Console.WriteLine(“Press enter to quit…”);

 Console.ReadLine();

 svcHost.Close();

 }

 catch (CommunicationException cex)

 {

 Console.WriteLine(“An exception occurred: {0}”, cex.Message);

 svcHost.Abort();

 }

 }

 

 

QUESTION 16

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

Explanation/Reference:

A factory that creates channels of different types that are used by clients to send messages to variously configured service endpoints.

ChannelFactory<TChannel> Class

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

 

 

QUESTION 17

You are working with a Windows Communication Foundation (WCF) client application that has a generated proxy named SampleServiceProxy. When the client application is executing, in line 04 of the following code, the channel faults (Line numbers are included for reference only.)

01 SampleServiceProxy proxy = new SampleServiceProxy();

02 try

03 {

04 proxy.ProcessInvoice(invoice);

05 }

06 catch

07 {

08 if(proxy.State == CommunicationState.Faulted)

09 {

10 …

11 }

12 }

13 proxy.UpdateCustomer(customer);

You need to return proxy to a state in which it can successfully execute the call in line 13. Which code segment should you use at line 10?

 

A. proxy.Close();

B. proxy = new SampleServiceProxy();

C. proxy.Abort();

D. proxy.Open();

 

Correct Answer: B

Explanation/Reference:CommunicationState Enumeration

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

 

 

QUESTION 18

A Windows Communication Foundation (WCF) service has a callback contract. You are developing a client application that will call this service. You must ensure that the client application can interact with the WCF service. What should you do?

 

A. On the OperationContractAttribute, set the AsyncPattern property value to true.

B. On the OperationContractAttribute, set the ReplyAction property value to the endpoint address of the client.

C. On the client, create a proxy derived from DuplexClientBase<TChannel>.

D. On the client, use GetCallbackChannel<T>.

 

Correct Answer: C

Explanation/Reference:

DuplexClientBase<TChannel> Class Used to create a channel to a duplex service and associate that channel with a callback object.

DuplexClientBase<TChannel> Class

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

 

 

QUESTION 19

You are creating a Windows Communication Foundation (WCF) service. You have the following requirements:

Messages must be sent over TCP

The service must support transactions.

Messages must be encoded using a binary encoding

Messages must be secured using Windows stream-based security.

You need to implement a custom binding for the service. In which order should the binding stack be configured?

 

A. tcpTransport, windowsStreamSecurity, transactionFlow, binaryMessageEncoding

B. transactionFlow, binaryMessageEncoding, windowsStreamSecurity, tcpTransport

C. windowsStreamSecurity, tcpTransport, binaryMessageEncoding, transactionFlow

D. binaryMessageEncoding, transactionFlow, tcpTransport, windowsStreamSecurity

 

Correct Answer: B

Explanation/Reference:

From higher to lower stack level

You can add binding elements by adding the desired BindingElement objects to its Elements collection.

The order in which the binding element is added is very important. The order of adding the binding elements is as follows:

1.

Transaction Flow (not required)

2.

Reliable Messaging (not required)

3.

Message Security (not required)

4.

Composite Duplex (not required)

5.

Message Encoding (required)

6.

Transport Security (not required)

7.

Transport (required)

Bindings

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

WCF Bindings in Depth

(http://msdn.microsoft.com/en-us/magazine/cc163394.aspx)

 

 

QUESTION 20

A Windows Communication Foundation (WCF) client configuration file contains the following XML segment in the system.serviceModel element.

<client>

 <endpoint address=”net.tcp://server/ContosoService”

binding=”netTcpBinding”

contract=”Contoso.IContosoService”

 name=”netTcp”/>

<endpoint address=”net.pipe://localhost/ContosoService”

binding=”netNamedPipeBinding”

contract=”Contoso.IContosoService”

 name=”netPipe” />

</client>

You need to create a channel factory that can send messages to the endpoint listening at net.pipe://localhost/ContosoService. Which code segment should you use?

 

clip_image004

 

Correct Answer: C

Explanation

Explanation/Reference:

ChannelFactory<TChannel> Constructor .NET Framework 4

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

Initializes a new instance of the ChannelFactory<TChannel> class.

ChannelFactory<TChannel> Constructors:

ChannelFactory<TChannel>() Initializes a new instance of the ChannelFactory<TChannel> class.

ChannelFactory<TChannel>(Binding) Initializes a new instance of the ChannelFactory<TChannel> class.

ChannelFactory<TChannel>(ServiceEndpoint) Initializes a new instance of the ChannelFactory<TChannel> class that produces channels with a specified endpoint.

***ChannelFactory<TChannel>(String) Initializes a new instance of the ChannelFactory<TChannel> class with a specified endpoint configuration name.

ChannelFactory<TChannel>(Type) Initializes a new instance of the ChannelFactory<TChannel> class.

ChannelFactory<TChannel>(Binding, EndpointAddress) Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and endpoint address.

ChannelFactory<TChannel>(Binding, String) Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and remote address.

ChannelFactory<TChannel>(String, EndpointAddress) Initializes a new instance of the ChannelFactory<TChannel> class associated with a specified name for the endpoint configuration and remote address.

 

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