Latest MCTS 70-513 Dumps Real Exam Download 91-100

Ensurepass

QUESTION 91

You develop a Windows Communication Foundation (WCF) service that employees use to access bonus information. You define the following service contract. (Line numbers are included for reference only.)

01 [ServiceContract(SessionMode = SessionMode.Required)]

02 public interface IFinancialService

03 {

04 [OperationContract]

05 string Login(int employeeID, string passwordHash);

06

07 [OperationContract]

08 double GetBonus(int month);

09

10 [OperationContract(IsTerminating = true)]

11 void Logout();

12 }

Client application can invoke methods without logging in. You need to ensure that the client applications invoke Login before invoking any other method. You also need to ensure that client applications cannot consume the service after invoking Logout. Which two action should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A. Replace line 04 with the following code.

[OperationContract(IsInitiating = false)]

B. Replace line 04 with the following code.

[OperationContract(IsInitiating = true, IsTerminating = true)]

C. Replace line 07 with the following code.

[OperationContract(IsInitiating = false)]

D. Replace line 10 with the following code.

[OperationContract(IsInitiating = false, IsTerminating = true)]

 

Correct Answer: CD

Explanation/Reference:OperationContractAttribute.IsInitiating

Gets or sets a value that indicates whether the method implements an operation that can initiate a session on the server (if such a session exists).

OperationContractAttribute.IsInitiating Property

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

 

 

QUESTION 92

You develop a Windows Communication Foundation (WCF) service that interacts with Microsoft Message Queuing (MSMQ). The service requires sessions.

You need to create a custom binding that enables messages sent to the queue to be viewed when you are using a listener tool.

Which binding elements should you use?

 

A. textMessageEncoding and msmqTransport in this order.

B. textMessageEncoding and msmqIntegrationTransport in this order.

C. msmqTransport and textMessageEncoding in this order.

D. msmqIntegrationTransport and textMessageEncoding in this order.

 

Correct Answer: A

Explanation/Reference:

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)

<textMessageEncoding>

Specifies the character encoding and message versioning used for text-based XML messages.

<msmqTransport>

Causes a channel to transfers messages on the MSMQ transport when it is included in a custom binding.

<textMessageEncoding>

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

<msmqTransport>

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

Message Queuing (MSMQ)

(http://msdn.microsoft.com/en-us/library/windows/desktop/ms711472(v=vs.85).aspx)

 

 

QUESTION 93

You are creating a Windows Communication Foundation (WCF) service. The service endpoints change frequently.

On the service, you add a new ServiceDiscoveryBehavior to the Behaviors collection of the ServiceHost Description property.

You need to ensure that client applications can communicate with the service and discover changes to the service endpoints.

What should you do?

 

A. Add a new ServiceDiscoveryBehavior to the Behaviors collection in the client application.

B. Add a new AnnouncementClient to the Behaviors collection in the client application.

C. Use the FindCriteria class and the UdpDiscoveryEndpoint class to set up the binding in the client application.

D. Use the DiscoveryProxy class and the EndpointDiscoveryMetadata class to set up the binding in the client application.

 

Correct Answer: C

Explanation/Reference:FindCriteria Class

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

UdpDiscoveryEndpoint Class

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

Configuring Discovery in a Configuration File

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

 

 

QUESTION 94

You are developing an application to update a users social status. You need to consume the service using Windows Communication Foundation (WCF). The client configuration is as follow.

<system.serviceModel><bindings><webHttpBinding><binding name=”SocialConfig”><security mode=”TransportCredentialOnly”><transport clientCredentialType=”Basic” realm=”Social API” /></security></binding>

</webHttpBinding>

</bindings>

<client>

 <endpoint address=”http://contoso.com” binding=”webHttpBinding”

bindingConfiguration=”SocialConfig”

contract=”ISocialStatus” name=”SocialClient” />

</client></system.serviceModel>

The service contract is defined as follows.

[ServiceContract]public interface ISocialStatus{

 [OperationContract]

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

void UpdateStatus(string text);

}

Which code segment should you use to update the social status?

 

A. using (WebChannelFactory<ISocialStatus> factory = new WebChannelFactory<ISocialStatus>(“SocialClient”))

{

 factory.Credentials.UserName.UserName = user.Name;

factory.Credentials.UserName.Password = user.Password;

ISocialStatus socialChannel = factory.CreateChannel();

socialChannel.UpdateStatus(newStatus);

}

B. using (ChannelFactory<ISocialStatus> factory = new WebChannelFactory<ISocialStatus>(typeof(ISocialStatus)))

{

 factory.Credentials.UserName.UserName = user.Name;

factory.Credentials.UserName.Password = user.Password;

ISocialStatus socialChannel = factory.CreateChannel();

socialChannel.UpdateStatus(newStatus);

}

C. using (ChannelFactory<ISocialStatus> factory = new ChannelFactory<ISocialStatus>(“POST”))

{

 factory.Credentials.Windows.ClientCredential.UserName = user.Name;

factory.Credentials.Windows.ClientCredential.SecurePassword.SetAt(0, Convert.ToChar(user.Password));

ISocialStatus socialChannel = factory.CreateChannel();

socialChannel.UpdateStatus(newStatus);

}

D. using (WebChannelFactory<ISocialStatus> factory = new WebChannelFactory<ISocialStatus>(typeof(ISocialClient)))

{

 factory.Credentials.Windows.ClientCredential.UserName = user.Name;

factory.Credentials.Windows.ClientCredential.SecurePassword.SetAt(0, Convert.ToChar(user.Password));

ISocialStatus socialChannel = factory.CreateChannel();

socialChannel.UpdateStatus(newStatus);

}

 

Correct Answer: A

Explanation/Reference:WebChannelFactory<TChannel>() Class

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

ChannelFactory<TChannel> Class

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

WebChannelFactory<TChannel>() Initializes a new instance of the WebChannelFactory<TChannel> class. WebChannelFactory<TChannel>(Binding) Initializes a new instance of the WebChannelFactory<TChannel> class. WebChannelFactory<TChannel>(ServiceEndpoint) Initializes a new instance of the WebChannelFactory<TChannel> class. WebChannelFactory<TChannel>(String) Initializes a new instance of the WebChannelFactory<TChannel> class.

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

WebChannelFactory<TChannel>(Uri) Initializes a new instance of the WebChannelFactory<TChannel> class with the specified Uri.

WebChannelFactory<TChannel>(Binding, Uri) Initializes a new instance of the WebChannelFactory<TChannel> class with the specified binding and Uri.

WebChannelFactory<TChannel>(String, Uri) Initializes a new instance of the WebChannelFactory<TChannel> class with the specified endpoint configuration and Uri.

 

 

QUESTION 95

You are developing a client application that uses the following code to consume a Windows Communication Foundation (WCF) service. (Line numbers are included for reference only.)

01 BasicHttpBinding myBinding = new BasicHttpBinding();

02 EndpointAddress myEndpointAddress = new EndpointAddress(“http://contoso.com/TaxService.svc”);

03 …

04 ITaxService client = channelFactory.CreateChannel();

05 string data = client.GetData(1);

You need to consume the service. Which code segment should you insert at line 03?

 

A.            var channelFactory = new ChannelFactory<ITaxService>();

B.            var channelFactory = new ChannelFactory<ITaxService>(myBinding);

C.            var channelFactory = new ChannelFactory<ITaxService>(myBinding, myEndpointAddress);

D.            var channelFactory = new ChannelFactory<ITaxService>(“http://contoso.com/TaxService.svc”);

 

Correct Answer: C

Explanation/Reference:ChannelFactory<TChannel> Class

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

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.

Delegation and Impersonation with WCF

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

Example:

public class HelloService : IHelloService

{ [OperationBehavior(Impersonation = ImpersonationOption.Required)]public string Hello(string message){

 WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;

if (callerWindowsIdentity == null)

{

 throw new InvalidOperationException

(“The caller cannot be mapped to a Windows identity.”);

}

using (callerWindowsIdentity.Impersonate())

{

 EndpointAddress backendServiceAddress = new EndpointAddress(“http://localhost:8000/ChannelApp”);

// Any binding that performs Windows authentication of the client can be used.

            ChannelFactory<IHelloService> channelFactory = new ChannelFactory<IHelloService>(new NetTcpBinding(), backendServiceAddress);

IHelloService channel = channelFactory.CreateChannel();

return channel.Hello(message);

}}}

 

 

QUESTION 96

clip_image002

A.            client.BeginGetFlight(GetFlightCallback, null);client.GetFlight();

B.            client.GetFlight();client.BeginGetFlight(GetFlightCallback, null);

C.            client.GetFlightCompleted += new EventHandler<GetFlightCompletedEventArgs>(GetFlightCallback);client.GetFlightAsync();

D.            IAsyncResult asyncResult = client.BeginGetFlight(GetFlightCallback, client);client.EndGetFlight(asyncResult);

 

Correct Answer: C

Explanation/Reference:

// AddAsync

double value1 = 100.00D;

double value2 = 15.99D;

client.AddCompleted += new EventHandler<AddCompletedEventArgs>(AddCallback);

client.AddAsync(value1, value2);

Console.WriteLine(“Add({0},{1})”, value1, value2);

How to: Call WCF Service Operations Asynchronously

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

 

 

QUESTION 97

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

The service operation takes a customer number as the only argument and returns information about the customer.

The service requires a security token in the header of the message. You need to create a message contract for the service.

Which code segment should you use?

 

A.            [ServiceContract]public interface IService{

 [OperationContract]

CustomerInformation GetCustomerInformation(Header header, int customerNumber);

}

[DataContract]

public class CustomerInformation

{

 

}

[MessageContract]

public class Header

{

 [MessageHeader]

public string SecurityTag;

}

B.            [ServiceContract]public interface IService{

 [OperationContract]

CustomerInformation GetCustomerInformation(Header header, int customerNumber);

}

[MessageContract]

public class CustomerInformation

{

 

}

[MessageContract]

public class Header

{

 [MessageHeader]

public string SecurityTag;

}

C.            [ServiceContract]public interface IService{

 [OperationContract]

CustomerInformation GetCustomerInformation(CustomerNumber request);

}

[DataContract]

public class CustomerInformation

{

 

}

[MessageContract]

public class CustomerNumber

{

 [MessageHeader]

public string SecurityTag;

 [MessageBodyMember]

public int CustomerNumberElement;

}

D.            [ServiceContract]public interface IService{

 [OperationContract]

CustomerInformation GetCustomerInformation(CustomerNumber request);

}

[MessageContract]

public class CustomerInformation

{

 

}

[MessageContract]

public class CustomerNumber

{

 [MessageHeader]

public string SecurityTag;

 [MessageBodyMember]

public int CustomerNumberElement;

}

 

Correct Answer: D

Explanation/Reference:Using Message Contracts

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

 

 

QUESTION 98

Your company has a Windows Communication Foundation (WCF) service at the URL http://services.contoso.com/OrderLookupService.svc. The <system.serviceModel> section of the configuration file is as follows. (Line numbers are included for reference only.)

01 <system.serviceModel>

02 <behaviors>

03 <serviceBehaviors>

04 <behavior>

05 <serviceDebug includeExceptionDetailInFaults=”false” />

06 …

07 </behavior>

08 </serviceBehaviors>

09 </behaviors>

10 <serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />

11 </system.serviceModel>

You need to ensure that the service publishes the WSDL description at http://services.contoso.com/OrderLookupService.svc?wsdl. What should you do?

 

A. Change the serviceDebug element at line 05 as follows.

<serviceDebug includeExceptionDetailInFaults=”true” />

B. Insert the following element at line 06.

<serviceDiscovery>

<announcementEndpoints>

<endpoint name=”wsdlAnnouncement” kind=”udpAnnouncementEndpoint” />

</announcementEndpoints>

</serviceDiscovery>

C. Insert the following element at line 06.

<serviceMetadata httpGetEnabled=”true” />

D. Insert the following element at line 06.

<serviceMetadata httpGetEnabled=”false” />

 

Correct Answer: C

Explanation/Reference:<serviceMetadata>

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

httpGetEnabled A Boolean value that specifies whether to publish service metadata for retrieval using an HTTP/Get request.                                 The default is false. If the httpGetUrl attribute is not specified, the address at which the metadata is published                                  is the service address plus a “?wsdl”. For example, if the service address is “http://localhost:8080/CalculatorService”, the HTTP/Get metadata address is “http://localhost:8080/CalculatorService?wsdl”.                                 If this property is false, or the address of the service is not based on HTTP or HTTPS, “?wsdl” is ignored.

 

 

QUESTION 99

A Windows Communication Foundation (WCF) service handles online order processing for your company.

You discover that many requests are being made with invalid account numbers.

You create a class named AccountNumberValidator that has a method named Validate.

Before the message is processed, you need to validate account numbers with AccountNumberValidator and reject messages with invalid account numbers.

You create a new class that implements the IParameterInspector interface. Which code segment should you use?

 

A.            public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)

{

 String accountNumber = GetAccountNumber(outputs);

var validator = new AccountNumberValidator();

if(validator.Validate(accountNumber))

{

 throw new FaultException();

}

}

public object BeforeCall(string operationName, object[]inputs)

{

 return null;

}

B.            public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState){

 return;

}

public object BeforeCall(string operationName, object[] inputs)

{

 string accountNumber = GetAccountNumber(inputs);

var validator = new AccountNumberValidator();

if (!validator.Validate(accountNumber))

{

 throw new FaultException();

 }}

C.            public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)

{ String accountNumber = GetAccountNumber(outputs);var validator = new AccountNumberValidator();if( !validator.Validate(accountNumber)){

 returnValue = new FaultException();

}}public object BeforeCall(string operationName, object[]inputs){

 return null;}

D.            public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState){

 return;}public object BeforeCall(string operationName, object[]inputs){

 string accountNumber = GetAccountNumber(inputs);

var validator = new AccountNumberValidator();

if (!validator.Validate(accountNumber))

{

 return new FaultException();}}

 

Correct Answer: B

Explanation/Reference:

Darth was right, there was no correct answer, the IParameterInspector does not expect exceptions as return values, they must be thrown.

I changed option B to represent a correct answer, its previous content was obviously wrong anyway.

AfterCall:

Called after client calls are returned and before service responses are sent.

On outbound calls from a client, the inspector is invoked before the request contents are serialized and sent to the service.

The inspector is also called after the response has been deserialized but before the return values have been dispatched to the proxy method.

On inbound calls to a service, the inspector is invoked after parameters are deserialized but before they are dispatched to the service operation.

BeforeCall:

Called before client calls are sent and after service responses are returned.

On outbound calls from a client, the inspector is invoked before the request contents are serialized and sent to the service.

The inspector is also called after the response has been deserialized but before the return values have been dispatched to the proxy method.

On inbound calls to a service, the inspector is invoked after the request contents are deserialized and dispatched to the service operation

and before the response contents are serialized and sent to the client.

 

 

QUESTION 100

You develop a Windows Communication Foundation (WCF) service to generate reports.

Client applications call the service to initiate report generation but do not wait for the reports to be generated.

The service does not provide any status to the client applications.

The service class is defined as follows. (Line numbers are included for reference only.)

01 [ServiceContract]

02 public class ReportGeneratorService

03 {

04   

05 06 07  private int GenerateReports(int clientID){ … 

08 09 10 }  }  return 0; 

You need to ensure that client applications can initiate reports without waiting for status.

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

 

A. Insert the following code at line 04.

[OperationContract(IsOneWay=true)]

B. Insert the following code at line 04.

[OperationContract(AsyncPattern=false)]

C. At line 05, change the GenerateReports method from private to public.

D. Remove line 08. At line 05, change the return type of GenerateReports method to void.

 

Correct Answer: AD

Explanation

Explanation/Reference:

How to: Create a One-Way Contract

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

One-way methods invoke operations on a Windows Communication Foundation (WCF) service from a client but do not expect a reply.

 

 

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