News:

SQL Table To C# Entity Model ConverterEntity Model (Class Properties) to SQL Table ConverterIf you encounter any trouble visiting our site, please contact us.

Mcq Answers for WCF

01 [ServiceContract]
02 public interface IService
03 {
04 [OperationContract]
05 string Operation1();
06 [OperationContract]
07 string Operation2();
08 }

You need to ensure that all calls to Operation1 and Operation2 from the client are encrypted and signed What should you do?

  1. Set the ProtectionLevel property in line 01 to EncryptAndSign.

  2. Set the ProtectionLevel property in line 04 and line 06 to Sign.

  3. Add a SecurityCriticalAttribute ror each operation.

  4. Add a SecunitySafeCriticalAttribute for each operation.

Answer: Answer is a

[ServiceContract]
public interface IOrderProcessing
{
[OperationContract]
void ApproveOrder(int id);
}

You need to ensure that only users with the Manager role can call the ApproveOrder method What should you do?

  1. In the method body, check the Rights PosessesProperty property to see if it contains Manager

  2. Add a PrincipalPermission attribute to the method and set the Roles property to Manager

  3. Add a SecurityPermission attribute to the method and set the SecurityAction to Demand.

  4. In the method body, create a new instance of WindowsClaimSet. Use the FindClaims method to locate a claimType named Roee with a right named Manager

Answer: Answer is b

  1. Set the value of ServiceSecurityContext.Current.WindowsIdentity.ImpersonationLevel to TokenlmpersonationLevel.Impersonation

  2. Set the value of ServiceSecurityContext.Current.Windowsldentity.ImpersonationLevel to TokenlmpersonationLevel.Delegation

  3. Set the PrincipalPermissionAttribute on the service contract and update the binding attribute in the endpoint element of the configuration file to wsHttpBinding

  4. Set the PnncipalPermissionAttribute on the service contract and update the bindingConfiguration attribute in the endpoint element of the configuration file to wsHttpBinding

Answer: Answer is b

  1. Set the ImpersonateCallerForAllOperations property of the service's ServiceAuthorizationBehavior to true. Apply an OperationBehavior attribute to OpA and set the Impersonation property to ImpersonationOption. Required Apply an OperationBehavior attribute to OpB and set the Impersonation property to ImpersonationOption. Allowed.

  2. Set the ImpersonateCallerForAllOperations property of the service's ServiceAuthorizationBehavior to true. Apply an OperationBehavior attribute to OpA and set the Impersonation property to ImpersonationOption. Allowed Apply an OperationBehavior attribute to OpB and set the Impersonation property to ImpersonationOption. NotAllowed

  3. Set the ImpersonateCallerForAllOperations property of the service's ServiceAuthorizationBehavior to false. Apply an OperationBehavior attribute to OpA and set the Impersonation property to ImpersonationOption. Allowed. Apply an OperationBehavior attribute to OpB and set the Impersonation property to ImpersonationOption. NotAllowed

  4. Set the ImpersonateCallerForAllOperations property of the service's ServiceAuthorizationBehavior to false. Apply an OperationBehavior attribute to OpA and set the Impersonation property to lmpersonationOption. Required. Apply an OperationBehavior attribute to OpB and set the Impersonation property to ImpersonationOption. Allowed.

Answer: Answer is d

  1. Within the service configuration, add a ServiceAuthorization behavior to the service, and set ImpersonateCallerForAllOperations to true.

  2. Within the service configuration, add a ServiceAuthenticationManager behavior to the service, and set ServiceAuthenticationManagerType to Impersonate.

  3. Within the service configuration, add a serviceSecurityAudit behavior to the service, and set serviceAuthorizationAuditLevel to SuccessOrFailure

  4. Within the service configuration, add a ServiceCredentials behavior to the service, and set type to Impersonate

Answer: Answer is a

  1. Set the authorizationManagerType attribute of the serviceAuthorization behavior to Message.

  2. Set the includeExceptionDetailslnFaults attribute of the serviceDebug behavior to true.

  3. Set the Mode attribute of the security configuration element to Message.

  4. Set the messageAuthenticationAuditLevel attribute of the serviceSecurityAudit behavior to Failure.

Answer: Answer is d

01 [ServiceContract]
02 public interface ITeamMessageService
03 {
04 [OperationContract]
05 string GetMessage();
07 [OperationContract]
08 void PutMessage(string message);
09 }

The code for the service class is as follows

10 public class TeamMessageService: ITeamMessageService
11 {
12 Guid key = Guid.NewGuid();
13 string message = "Today's Message":
14 public string GetMessage()
15 {
16 return stringFormat("Message:{0} Key:{1}",
17 message, key);
18 }
19 public void PutMessage(string message)
20 {
21 this.message = message;
22 }
23 }

The service is self-hosted. The hosting code is as follows.

24 ServiceHost host = New ServiceHost(GetType(TeamMessageService));
25 BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None):
26 host.AddServiceEndpoint(MyApplication.ITeamMessageService, binding, "http://
localhost:12345");
27 host Open();

You need to ensure that all clients calling GetMessage will retrieve the same string, even if the message is updated by clients calling PutMessage.

What should you do?

  1. Add the following attribute to the TeamMessageService class, before line 10.

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  2. Add the following attribute to the TeamMessageService class, before line 10.

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

    Then change the binding definition on the service at line 25, and on the client to the following

    WSHttpBinding binding new WSHttpBinding(SecurityModeNone);
    binding ReliableSession.Enabled = true;
  3. Pass a service instance to the instancing code in line 24, as follows.

    ServiceHost host = new ServiceHost(new TeamMessageService());
  4. Redefine the message string in line 13, as follows

    static string message = "Today's Message":

    Then change the implementation of PutMessage in lines 19-22 to the following

    public void PutMessage(string message) { TeamMessageServiceMessage.PutMessage }
Answer: Answer is a

01 [ServiceContract]
02 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
03 public class DataAccessService
04 {
05 [OperationContract]
06 public void PutMessage(string message)
07 {
08 MessageDatabase.PutMessage(message);
09 }
10 [OperationContract]
11 pubic string[] SearchMessages(string search)
12 {
13 return MessageDatabase.SearchMessages(search);
14 }
15 }

MessageDatabase supports a limited number of concurrent executions of its methods. You need to change the service to allow up to the maximum number of executions of the methods of MessageDatabase. This should be implemented without preventing customers from connecting to the service. What should you do?

  1. Change the service behavior as follows.

    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
  2. Change the service behavior as follows.

    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerSession)]
  3. Add a throttling behavior to the service, and configure the maxConcurrentCalls.

  4. add a throttling behavior to the service, and configure the maxConcurrentSessions.

Answer: Answer is c

ServiceHost host = new ServiceHost(typeof(CounterService));
NetTcpBinding binding1 = new NetTcpBinding(SecurityMode.None);
host.AddServiceEndpoint("MyApplication.ICounterService", binding1, "net.tcp://localhost:23456");
host.Open();

This service is currently exposed over TCP, but needs to be exposed to external clients over HTTP. Therefore,
a new service endpoint is created with the following code.

host.AddServiceEndpoint("MyApplication.ICounterService", binding2, "http://localhost:12345");

You need to complete the implementation and ensure that the session-based counter will perform over HTTP as it does over TCP. What should you do?

  1. Define binding2 as follows

    WS2007HttpBinding binding2 = new WS2007HttpBinding(SecurityMode.None);

    Configure binding2 as follows

    binding2.ReliableSession.Enabled = true;
  2. Define binding2 as follows

    WSHttpBinding binding2 = new WSHttpBinding(SecurityMode.None);

    Add the following behavior to the service implementation

    ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
  3. Define binding2 as follows.

    BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.None);

    Enable cookies for binding2.

    binding2.AllowCookies = true:
  4. Define binding2 as follows

    BasicHttpBinding binding2 = new BasicHttpBinding(Basic HttpSecurityMode.None)

    Add the following behavior to the service implementation.

    [ServiceBehavior(InstanceContexMode = InstanceContextMode.Single)]
Answer: Answer is a

[ServiceContract(SessionMode=SessionMode.Allowed)]
public interface IMyService
{
[OperationContract(IsTerminating=false)]
void Initialize();
[OperationContract(IsInitiating=false)]
void DoSomething();
[OperationContract(IsTerminating=true)]
void Terminate();
}

You need to change this interface so that: lnitialize is allowed to be called at any time before Terminate is called. DoSomething is allowed to be called only after Initialize is called, and not allowed to be called after Terminate is called. Terminate will be allowed to be called only after Initalize is called Which two actions should you perform? (Each correct answer presents part of the sdution. Choose two)

  1. Change the ServiceContract attribute of the IMyService interface to the following.

    [ServiceContract(SessionMode=SessionMode.Required)]
  2. Change the ServiceContract attrbute of the IMyService interface to the following

    [ServiceContract(SessionMode=SessionMode.Allowed)]
  3. Change the OperationContract attribute of the Initialize operation to the following.

    [OperationContract(IsInitiating = true, IsTerminating = false)]
  4. Change the OperationContract attribute of the Terminate operation to the following

    [OperationContract(IsInitiating = false, IsTerminating = true)]
Answer: Answer is a, d

Advertisement

BCS Preparation now even more easy. ReadBD is the place where you can find all kind of resources to be successful in BCS,Bank,Islami Bank exam and interview.

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;