70-513

TS: Windows Communication Foundation Development with Microsoft .NET Framework 4


Note: The answer is for reference only, you need to understand all question.
QUESTION 1
You are creating a Windows Communication Foundation (WCF) service that is implemented as follows. (Line numbers are included for reference only.)
01 [ServiceContract] 02 [ServiceBehavior(IncludeExceptionDetailsInFaults = true)] 03 public class OrderService 04 { 05 [OperationContract] 06 public void SubmitOrder(Order anOrder) 07 { 08 try 09 { 10 ... 11 } 12 catch(DivideByZeroException ex) 13 { 15 } 16 } 17 }
You need to ensure that the stack trace details of the exception are not included in the error information sent to the client.
What should you do?
A.Replace line 14 with the following line: throw; B.Replace line 14 with the following line: throw new FaultException(anOrder, ex.ToString()); C.After line 05, add the following line: [FaultContract(typeof(FaultException))]
Replace line 14 with the following line: throw ex; D.After line 05, add the following line: [FaultContract(typeof(FaultException))]
Replace line 14 with the following line: throw new FaultException(anOrder, "Divide by zero exception");

Answer: D


QUESTION 2
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) { ... }
}
Answer: C


QUESTION 3
You are developing a data contract for a Windows Communication Foundation (WCF) service. The data in the data contract must participate in round trips. Strict schema validity is not required. You need to ensure that the contract is forward-compatible and allows new data members to be added to it.
Which interface should you implement in the data contract class?
A. ICommunicationObject
B. IExtension
C. IExtensibleObject
D. IExtensibleDataObject
Answer: D


QUESTION 4
Windows Communication Foundation (WCF) application uses a data contract that has several data members. You need the application to throw a SerializationException if any of the data members are not present when a serialized instance of the data contract is deserialized.
What should you do?
A.Add the KnownType attribute to the data contract. Set a default value in each of the data member declarations. B.Add the KnownType attribute to the data contract. Set the Order property of each data member to unique integer value. C.Set the EmitDefaultValue property of each data member to false. D.Set the IsRequired property of each data member to true.

Answer: D


QUESTION 5
A Windows Communication Foundation (WCF) application uses the following data contract.
[DataContract] public class Person {
[DataMember] public string firstName;
[DataMember] public string lastName;
[DataMember] public int age;
[DataMember] public int ID; }
You need to ensure that the following XML segment is generated when the data contract is serialized.
999999999

Which code segment should you use?
A.[DataMember] public string firstName; [DataMember] public string lastName; [DataMember(EmitDefaultValue = true)] public int age = 0; [DataMember(EmitDefaultValue = true)] public int ID = 999999999;
B.[DataMember(EmitDefaultValue = false)] public string firstName = null; [DataMember(EmitDefaultValue = false)]

public string lastName = null; [DataMember(EmitDefaultValue = true)] public int age = -1; [DataMember(EmitDefaultValue = false)] public int ID = 999999999;
C.[DataMember(EmitDefaultValue = true)] public string firstName; [DataMember(EmitDefaultValue = true)] public string lastName; [DataMember(EmitDefaultValue = false)] public int age = -1; [DataMember(EmitDefaultValue = false)] public int ID = 999999999;
D.[DataMember] public string firstName = null; [DataMember] public string lastName = null; [DataMember(EmitDefaultValue = false)] public int age = 0; [DataMember(EmitDefaultValue = false)] public int ID = 999999999;
Answer: D


QUESTION 6
The following is an example of a SOAP envelope:

...
2469

You need to create a message contract that generates the SOAP envelope. Which code segment should you use:

A.[MessageContract(WrapperName="http://www.contoso.com")] public class CheckStockRequest {
[MessageHeader(Name="http://www.contoso.com")] public int StoreId{get; set;} [MessageBodyMember(Name="http://www.contoso.com")] public int ItemId{get; set;}
} B.[MessageContract(WrapperNamespace="http://www.contoso.com")] public class CheckStockRequest { [MessageHeader(Namespace="http://www.contoso.com")] public int StoreId{get; set;} [MessageBodyMember(Namespace="http://www.contoso.com")] public int ItemId{get; set;} } C.[MessageContract(WrapperNamespace="http://www.contoso.com")] public class CheckStockRequest { [MessageHeader(Namespace="http://www.contoso.com")] public int StoreId{get; set;} public int ItemId{get; set;} } D.[MessageContract(WrapperNamespace="http://www.contoso.com")] public class CheckStockRequest { [MessageHeader(Namespace="http://www.contoso.com")] public int StoreId{get; set;} [MessageBodyMember] public int ItemId{get; set;} }
Answer: B


QUESTION 7
You are developing a client that sends several types of SOAP messages to a Windows Communication Foundation (WCF) service method named PostData. PostData is currently defined as follows:
[OperationContract] void PostData(Order data);
You need to modify PostData so that it can receive any SOAP message. Which code segment should you use?

A.[OperationContract(IsOneWay = true, Action = "*", ReplyAction = "*")] void PostData(Order data); B.[OperationContract(IsOneWay = true, Action = "*", ReplyAction = "*")] void PostData(BodyWriter data); C.[OperationContract] void PostData(BodyWriter data); D.[OperationContract] void PostData(Message data);
Answer: D


QUESTION 8
A class named TestService implements the following interface:
[ServiceContract] public interface ITestService {
[OperationContract] DateTime GetServiceTime(); }
TestService is hosted in an ASP.NET application. You need to modify the application to allow the GetServiceTime method to return the data formatted as JSON. It must do this only when the request URL ends in /ServiceTime.
What should you do?
A.Add this attribute to the GetServiceTime method: [WebInvoke(Method="POST")]
In the web.config file, add this element to system.serviceModel/behaviors/endpointBehaviors:
In the web.config file, configure TestService in the system.serviceModel/services collection as follows:

B.Add this attribute to the GetServiceTime method: [WebInvoke(Method="GET", UriTemplate="/ServiceTime", ResponseFormat=WebMessageFormat.Json)]

In the web.config file, configure TestService in the system.serviceModel/services collection as follows: C.Add this attribute to the GetServiceTime method: [WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate="/ServiceTime")]
Create a new .svc file named JsonVersion.svc with the following content: <%@ ServiceHost Service="TestService" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
D.Add this attribute to the GetServiceTime method: [WebGet(UriTemplate = "{Json}/ServiceTime")]
Create a new .svc file named JsonVersion.svc with the following content: <%@ ServiceHost Service="TestService" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
Answer: C


QUESTION 9
You are creating a Windows Communication Foundation (WCF) service that implements operations in a RESTful manner. You need to add a delete operation. You implement the delete method as follows.
string void DeleteItems(string id);
You need to configure WCF to call this method when the client calls the service with the HTTP DELETE operation.
What should you do?
A.Add the WebInvoke(UriTemplate="/Items/{id}", Method="DELETE") attribute to the operation. B.Add the HttpDelete attribute to the operation. C.Replace the string parameter with a RemovedActivityAction parameter. D.Replace the return type with RemovedActivityAction.
Answer: A
QUESTION 10
A Windows Communication Foundation (WCF) service uses the following service contract.

[ServiceContract]
public interface IService
{ [OperationContract] string Operation1(string s);
}
You need to ensure that the operation contract Operation1 responds to HTTP POST requests.
Which code segment should you use?
A.[OperationContract] [WebInvoke(Method="POST")] string Operation1(string s);
B.[OperationContract] [WebGet(UriTemplate="POST")] string Operation1(string s);
C.[OperationContract(ReplyAction="POST")] string Operation1(string s);
D.[OperationContract(Action="POST")] string Operation1(string s);
Answer: A


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 lep = new List(); 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)
Answer: B


QUESTION 12
You are modifying an existing Windows Communication Foundation (WCF) service that is defined as follows.
[ServiceContract]
public interface IMessageProcessor { [OperationContract] void ProcessMessage();
}
public class MessageProcessor : IMessageProcessor {
public void ProcessMessage() { ... SummitOrder(); ...
} } 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=ConcurrencyMode.Reentrant) B.CallbackBehavior(ConcurrencyMode=ConcurrencyMode.Multiple) C.ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Reentrant) D.ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Multiple)
Answer: C


QUESTION 13
A Windows Communication Foundation (WCF) service listens for messages at net.tcp://www.contoso.com/MyService. It has a logical address at http://www.contoso.com/MyService. The configuration for the WCF client is as follows.

The generated configuration does not provide enough information for the client to communicate with the server. You need to update the client so that it can communicate with the server.
What should you do?
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.co m/MyService.
C.After instantiating the client and before invoking any service operation, add this line of code.
client.Endpoint.Behaviors.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/MyService")));

Answer: D
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;
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.IDataAccess"); C.host = new ServiceHost(typeof(IDataAccess)); D.host = new ServiceHost(typeof(DataAccessService));
Answer: D
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 = CreateHose(); svcHost.Open(); Console.ReadLine(); SrvHost.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"); return 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"); return svcHost;
Answer: A 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
B. ServiceHost
C. ClientRuntime
D. CommunicationObject

Answer: A
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 02 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 {
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();
Answer: C 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 Operation Contract Attribute, set the AsyncPattern property value to true. B.On the Operation Contract Attribute, set the ReplyAction property value to the endpoint address of the client. C.On the client, create a proxy derived from DuplexClientBase. D.On the client, use GetCallbackChannel.

Answer: C
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

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




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
A.ChannelFactory factory = new ChannelFactory("Contoso.IContoso"); B.ChannelFactory factory = new ChannelFactory("netNamedPipeBinding"); C.ChannelFactory factory = new ChannelFactory("netPipe");
D.ChannelFactory factory = new ChannelFactory( "net.pipe://localhost/ContosoService");

Answer: C
QUESTION 21
. 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 } 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 InstanceContext callbackContext = new InstanceContext(new NameService("client")); ... 25 DuplexChannelFactory factory = new DuplexChannelFactory(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 factory = new DuplexChannelFactory(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) ;
Answer: AB QUESTION 22

A Windows Communication Foundation (WCF) solution exposes the following contract over an HTTP connection.
[ServiceContract] public interface IDataService {
[OperationContract] string GetData(); }
Existing clients are making blocking calls to GetData. Calls to GetData take five seconds to complete. You need to allow new clients to issue non-blocking calls to get the data, without breaking any existing clients.
What should you do
A.Replace the service interface with the following interface and implement the new methods. [ServiceContract] public interface IDoSomething {
[OperationContract] string DoLongOperation();
[OperationContract(AsyncPattern = true)] IAsyncResult BeginDoLongOperation();
[OperationContract(AsyncPattern = true)] string EndDoLongOperation(IAsyncResult result); }
B.Replace the service interface with the following interface and implement the new methods. [ServiceContract] public interface IDoSomething {
[OperationContract(AsyncPattern=true)] IAsyncResult BeginDoLongOperation();
[OperationContract(AsyncPattern=true)] string EndDoLongOperation(IAsyncResult result); } C.Generate a proxy class with asynchronous methods and use it for the new clients. D.Add a new endpoint to the service that uses a full-duplex binding and use it for the new clients.


Answer: C
QUESTION 23
A Windows Communication Foundation (WCF) service implements the following contract. (Line numbers are included for reference only.)
01 [ServiceContract] 02 public interface IDataAccessService 03 { 04 [OperationContract] 05 void PutMessage(string message);
07 [OperationContract] 08 [FaultContract(typeof(TimeoutFaultException))] 09 [FaultContract(typeof(FaultException))] 10 string[] SearchMessages(string search); 11 }
The implementation of the SearchMessages method throws TimeoutFaultException exceptions for database timeouts. The implementation of the SearchMessages method also throws an Exception for any other issue it encounters while processing the request. These exceptions are received on the client side as generic FaultException exceptions. You need to implement the error handling code for SearchMessages and create a new channel on the client only if the channel faults.
What should you do
A.Catch and handle both TimeoutFaultException and FaultException. B.Catch both TimeoutFaultException and FaultException. Create a new channel in both cases. C.Catch and handle TimeoutFaultException. Catch FaultException and create a new channel. D.Catch and handle FaultException. Catch TimeoutFaultException and create a new channel.

Answer: C
QUESTION 24
You are consuming a Windows Communication Foundation (WCF) service in an ASP.NET Web application. The service interface is defined as follows.
[ServiceContract] public interface ICatalog {
[OperationContract]

[WebGet(UriTemplate = "/Catalog/Items/{id}", ResponseFormat = WebMessageFormat.Json)] string RetrieveItemDescription(int id);
}
The service is hosted at /Catalog.svc. You need to call the service using jQuery to retrieve the description of an item as indicated by a variable named itemId.
Which code segment should you use?
A.$.get(String.format("/Catalog.svc/Catalog/Items/id={0}", itemId) null, function (data) { ... }, "javascript");
B.$.get(String.format("/Catalog.svc/Catalog/Items/{0}", itemId), null, function (data) { ... }, "json");
C.$.get(String.format("/Catalog.svc/Catalog/Items/{0}", itemId), null, function (data) { ... }, "xml");
D.$.get(String.format("/Catalog.svc/Catalog/Items/id={0}", itemId), null, function (data) { ... }, "json");

Answer: B
QUESTION 25
You are consuming a Windows Communication Foundation (WCF) service. The service interface is defined as follows.
[DataContract(Namespace = "")] public class Item { ... } [ServiceContract(Namespace = "")] public interface ICatalog { [OperationContract]

[WebInvoke(Method = "POST", UriTemplate = "/Item")] Item UpdateItem(Item item); }
The client application receives a WebResponse named response with the response from the service. You need to deserialize this response into a strongly typed object representing the return value of the method.
Which code segment should you use?
A.DataContractSerializer s = new DataContractSerializer(typeof(Item)); Item item = s.ReadObject(response.GetResponseStream()) as Item; B.BinaryFormatter f = new BinaryFormatter(); Item item = f.Deserialize(response.GetResponseStream()) as Item;
C.XmlDictionaryReader r = JsonReaderWriterFactory.CreateJsonReader( response.GetResponseStream(), XmlDictionaryReaderQuotas.Max); DataContractSerializer s = new DataContractSerializer(typeof(Item)); Item item = s.ReadObject(r) as Item;
D.DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(Item)); Item item = s.ReadObject(response.GetResponseStream()) as Item;

Answer: A
QUESTION 26
You are developing an application to update a user's social status. You need to consume the service using Windows Communication Foundation (WCF).
The client configuration is as follows.




The service contract is defined as follows. [ServiceContract] public interface ISocialStatus { [OperationContract] [WebInvoke(UriTemplate = "/statuses/update.xmlstatus={text}")] void UpdateStatus(string text); }
Which code segment should you use to update the social status?
A.using (WebChannelFactory factory = new WebChannelFactory("SocialClient")) {
factory.Credentials.UserName.UserName = user.Name; factory.Credentials.UserName.Password = user.Password; ISocialStatus socialChannel = factory.CreateChannel(); socialChannel.UpdateStatus(newStatus);
} B.using (ChannelFactory factory = new WebChannelFactory(typeof(ISocialStatus))) { factory.Credentials.UserName.UserName = user.Name; factory.Credentials.UserName.Password = user.Password; ISocialStatus socialChannel = factory.CreateChannel(); socialChannel.UpdateStatus(newStatus); } C.using (ChannelFactory factory = new ChannelFactory("POST")) { factory.Credentials.Windows.ClientCredential.UserName = user.Name; factory.Credentials.Windows.ClientCredential.SecurePassword.SetAt(0, user.Password); ISocialStatus socialChannel = factory.CreateChannel(); socialChannel.UpdateStatus(newStatus); } D.using (WebChannelFactory factory = new WebChannelFactory(typeof(ISocialClient))) { factory.Credentials.Windows.ClientCredential.UserName = user.Name; factory.Credentials.Windows.ClientCredential.SecurePassword.SetAt(0, user.Password); ISocialStatus socialChannel = factory.CreateChannel(); socialChannel.UpdateStatus(newStatus); }


Answer: A
QUESTION 27
A Windows Communication Foundation (WCF) client application is consuming an RSS syndication feed from a blog. You have a SyndicationFeed variable named feed. The application iterates through the items as follows. (Line numbers are included for reference only.)
01 foreach (SyndicationItem item in feed.Items) 02 { 03 }
You need to display the content type and body of every syndication item to the console.
Which two lines of code should you insert between lines 02 and 03?
A.Console.WriteLine(item.Content.Type); Console.WriteLine(((TextSyndicationContent)item.Content).Text); B.Console.WriteLine(item.Content.GetType()); Console.WriteLine(((TextSyndicationContent)item.Content).Text); C.Console.WriteLine(item.Content.Type); Console.WriteLine(item.Content.ToString()); D.Console.WriteLine(item.Content.GetType()); Console.WriteLine(item.Content.ToString());

Answer: A
QUESTION 28
You are creating a Windows Communication Foundation (WCF) service to process orders. The data contract for the order is defined as follows.
[DataContract] public class Order { ... [DataMember] public string CardHolderName { get; set; [DataMember] public string CreditCardNumber { get; set; } }
You have the following requirements:

Enable the transmission of the contents of Order from the clients to the service. Ensure that the contents of
CreditCardNumber are not sent across the network in clear text. Ensure that the contents of CreditCardNumber are accessible by the service to process the order. You need to implement the service to meet these requirements. What should you do?
A.Add a DataProtectionPermission attribute to the CreditCardNumber property and set the ProtectData property to true. B.Convert the DataContract to a MessageContract and set the ProtectionLevel property to SignAndEncrypt. C.Change the data type of CreditCardNumber from string to SecureString.
D.Implement the CreditCardNumber property getter and setter. In the setter, run the value of the CreditCardNumber through the MD5CryptoServiceProvider class TransformBlock method.

Answer: B
QUESTION 29
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 string CodeName { get; set; } public string SecretHandshake { get; set; } }
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.


Answer: A
QUESTION 30
A Windows Communication Foundation (WCF) client uses the following service contract. (Line numbers are included for reference only.)
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?
A. Set the ProtectionLevel property in line 01 to EncryptAndSign.
B. Set the ProtectionLevel property in line 04 and line 06 to Sign.
C. Add a SecurityCriticalAttribute for each operation.
D. Add a SecuritySafeCriticalAttribute for each operation.

Answer: A
QUESTION 31
You are creating a Windows Communication Foundation (WCF) service that implements the following service contract.
[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?
A. In the method body, check the Rights.PosessesProperty property to see if it contains Manager.
B. Add a PrincipalPermission attribute to the method and set the Roles property to Manager.
C. Add a SecurityPermission attribute to the method and set the SecurityAction to Demand.
D. In the method body, create a new instance of WindowsClaimSet. Use the FindClaims method to locate a claimType named Role with a right named Manager.

Answer: B
QUESTION 32
You are developing a Windows Communication Foundation (WCF) service. The service needs to access out-of-process resources. You need to ensure that the service accesses these resources on behalf of the originating caller.
What should you do?
A.Set the value of ServiceSecurityContext.Current.WindowsIdentity.ImpersonationLevel to TokenImpersonationLevel.Impersonation. B.Set the value of ServiceSecurityContext.Current.WindowsIdentity.ImpersonationLevel to TokenImpersonationLevel.Delegation. C.Set the PrincipalPermissionAttribute on the service contract and update the binding attribute in the endpoint element of the configuration file to wsHttpBinding. D.Set the PrincipalPermissionAttribute on the service contract and update the bindingConfiguration attribute in the endpoint element of the configuration file to wsHttpBinding.

Answer: B
QUESTION 33
A Windows Communication Foundation (WCF) service exposes two operations: OpA and OpB. OpA needs to execute under the client's identity, and OpB needs to execute under the service's identity.
You need to configure the service to run the operations under the correct identity.
What should you do?
A.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.

B.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.
C.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.
D.Set the ImpersonateCallerForAllOperations property of the service's ServiceAuthorizationBehavior to false. 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.

Answer: D
QUESTION 34
A Windows Communication Foundation (WCF) service that handles corporate accounting must be changed to comply with government regulations of auditing and accountability. You need to configure the WCF service to execute under the Windows logged-on identity of the calling application.
What should you do?
A.Within the service configuration, add a ServiceAuthorization behavior to the service, and set ImpersonateCallerForAllOperations to true. B.Within the service configuration, add a ServiceAuthenticationManager behavior to the service, and set ServiceAuthenticationManagerType to Impersonate. C.Within the service configuration, add a serviceSecurityAudit behavior to the service, and set serviceAuthorizationAuditLevel to SuccessOrFailure. D.Within the service configuration, add a ServiceCredentials behavior to the service, and set type to Impersonate.
Answer: A
QUESTION 35
You have a secured Windows Communication Foundation (WCF) service.
You need to track unsuccessful attempts to access the service.

What should you do?
A.Set the authorizationManagerType attribute of the serviceAuthorization behavior to Message. B.Set the include ExceptionDetailsInFaults attribute of the serviceDebug behavior to true. C.Set the Mode attribute of the security configuration element to Message. D.Set the message AuthenticationAuditLevel attribute of the serviceSecurityAudit behavior to Failure.

Answer: D
QUESTION 36
A Windows Communication Foundation (WCF) solution uses the following contract to share a message across its clients. (Line numbers are included for reference only.)
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 string.Format("Message:{0}. Key:{1}", message, Key);
17 }
18

19 public void PutMessage(string message) 20 { DoSomething()
this.message = message; 22 } 23 }
The service is self-hosted. The hosting code is as follows.
24 ServiceHost host = new serviceHost(typeof(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?
A. Add the following attribute to the TeamMessageService class, before line 10. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
B. 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(SecurityMode.None); binding.ReliableSession.Enabled = true;
C. Pass a service instance to the instancing code in line 24, as follows. ServiceHost host = new ServiceHost(new TeamMessageService());
D. 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) {
TeamMessageService.message = message; }

Answer: A
QUESTION 37
A Windows Communication Foundation (WCF) solution exposes the following service over a TCP binding. (Line numbers are included for reference only.)
01[ServiceContract] 02[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)] 03public class DataAccessService 04{ 05[OperationContract] 06public void PutMessage(string message) 07{

08MessageDatabase.PutMessage(message); 09} 10[OperationContract] 11public string[] SearchMessages(string search) 12{ 13return 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?
A. Change the service behavior as follows. [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
B. Change the service behavior as follows. [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerSession)]
C. Add a throttling behavior to the service, and configure the maxConcurrentCalls.
D. Add a throttling behavior to the service, and configure the maxConcurrentSessions.

Answer: C
QUESTION 38
A Windows Communication Foundation (WCF) solution provides a session-based counter. The service is self-hosted. The hosting code is as follows.
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?
A.Define binding2 as follows.WS2007HttpBinding binding2 = new WS2007HttpBinding(SecurityMode.None);
Configure binding2 as follows:
binding2.ReliableSession.Enabled = true; B.Define binding2 as follows.WSHttpBinding binding2 = new WSHttpBinding(SecurityMode.None);
Add the following behavior to the service implementation:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
C.Define binding2 as follows.BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.None);
Enable cookies for binding2:
binding2.AllowCookies = true;
D.Define binding2 as follows.BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.None);
Add the following behavior to the service implementation:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

Answer: A
QUESTION 39
A Windows Communication Foundation (WCF) solution uses the following contract.
[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:
initialize 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 Initialize is called.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Change the ServiceContract attribute of the IMyService interface to the following. ServiceContract(SessionMode = SessionMode.Required)
B. Change the ServiceContract attribute of the IMyService interface to the following. ServiceContract(SessionMode = SessionMode.Allowed)
C. Change the OperationContract attribute of the Initialize operation to the following. OperationContract(IsInitiating = true, IsTerminating = false)
D. Change the OperationContract attribute of the Terminate operation to the following. OperationContract(IsInitiating = false, IsTerminating = true)

Answer: AD
QUESTION 40
A Windows Communication Foundation (WCF) client and service share the following service contract interface.
[ServiceContract] public interface IContosoService {
[OperationContract] void SavePerson(Person person); }
They also use the following binding.
NetTcpBinding binding = new NetTcpBinding { TransactionFlow = true };
The client calls the service with the following code.
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{ IContosoService client = factory.CreateChannel(); client.SavePerson(person); Console.WriteLine(Transaction.Current.TransactionInformation.DistributedIdentifier); ts.Complete();
} The service has the following implementation for SavePerson.

public void IContosoService.SavePerson(Person person)
{ person.Save(); Console.WriteLine(Transaction.Current.TransactionInformation.DistributedIdentifier);
}
The distributed identifiers do not match on the client and the server. You need to ensure that the client and server enlist in the same distributed transaction.
What should you do?
A. Add the following attributes to the SavePerson operation on IContosoService. [OperationBehavior(TransactionScopeRequired = true)] [TransactionFlow(TransactionFlowOption.Mandatory)]
B. Add the following attributes to the SavePerson operation on IContosoService. [TransactionFlow(TransactionFlowOption.Mandatory)] [OperationBehavior(TransactionScopeRequired = true)]
C. Add the following attribute to the SavePerson operation on IContosoService. [OperationBehavior(TransactionScopeRequired = true)]
Add the following attribute to the implementation of SavePerson. [TransactionFlow(TransactionFlowOption.Allowed)]
D. Add the following attribute to the SavePerson operation on IContosoService. [TransactionFlow(TransactionFlowOption.Allowed)]
Add the following attribute to the implementation of SavePerson. [OperationBehavior(TransactionScopeRequired = true)]
Answer: D
QUESTION 41
A service implements the following contract. (Line numbers are included for reference only.)
01 [ServiceContract(SessionMode = SessionMode.Required)] 02 public interface IContosoService 03 { 04 [OperationContract(IsOneWay = true, IsInitiating = true)] 05 void OperationOne(string value);

07 [OperationContract(IsOneWay = true, IsInitiating = false)] 08 void OperationTwo(string value); 09 }
The service is implemented as follows.
20 class ContosoService : IContosoService 21 { 22 public void OperationOne(string value) { ... } 24 public void OperationTwo(string value) { ... } 25 }
ContosoService uses NetMsmqBinding to listen for messages. The queue was set up to use transactions for adding and removing messages. You need to ensure that OperationOne and OperationTwo execute under the same transaction context when they are invoked in the same session.
What should you do?
A.Insert the following attribute to OperationOne on IContosoService. [TransactionFlow(TransactionFlowOption.Mandatory)]
Insert the following attribute to OperationTwo on IContosoService. [TransactionFlow(TransactionFlowOption.Mandatory)] B.Insert the following attribute to OperationOne on ContosoService. [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = false)]
Insert the following attribute to OperationTwo on ContosoService. [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)] C.Add the following XML segment to the application config file in the system.serviceModel/bindings configuration section.

Then use the NetMsmqBinding named contosoTx to listen for messages from the clients. D.Add the following XML segment to the application config file in the system.serviceModel/bindings configuration section.




Then use the CustomBinding named contosoTx to listen for messages from the clients.

Answer: B
QUESTION 42
A WCF service code is implemented as follows.
(Line numbers are included for reference only.)
01 [ServiceContract]
02 [ServiceBehavior(InstanceContextMode =
03 InstanceContextMode.Single)]
04 public class CalculatorService
05 {
06 [OperationContract]
07 public double Calculate(double op1, string op, double op2)
08 {
...
24 }
25 }
You need to increase the rate by which clients get the required response from the service.
What are two possible ways to achieve this goal? (Each correct answer presents a complete solution, choose two.)
A.Change the service behavior to the following. [ServiceBehavior( InstanceContextMode=InstanceContextMode.Single, ConcurrencyMode=ConcurrencyMode.Multiple)]
B.Change the service behavior to the following. [ServiceBehavior( InstanceContextMode=InstanceContextMode.PerCall)]
C.Require the clients use threads, the Parallel Task Library, or other mechanism to issue service calls in parallel.
D.Require the clients to use async operations when calling the service.
Answer: AB QUESTION 43

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 [ServiceContract] 08 public interface INameService 09 { 10 [OperationContract] 11 string GetName(); 12 }
The code that implements the IGreetingService interface is as follows.
20 public class GreetingService : IGreetingService 21 { 22 public string GetMessage() 23 { 24 INameService clientChannel = OperationContext.Current.GetCallbackChannel(); 25 string clientName = clientChannel.GetName(); 26 return String.Format("Hello {0}", clientName); 27 } 28 }
The service is self-hosted. The hosting code is as follows.
30 ServiceHost host = new ServiceHost(typeof(GreetingService)); 31 NetTcpBinding binding = new NetTcpBinding(SecurityMode.None); 32 host.AddServiceEndpoint("MyApplication.IGreetingService", binding, "net.tcp://localhost:12345"); 33 host.Open();
The code that implements the INameService interface is as follows.
40 class NameService : INameService 41 { 42 string name; 43 public NameService(string name) 44 { 45 this.name = name;

46 } 47 public string GetName() 48 { 49 return name; 50 } 51 }
Currently, this code fails at runtime, and an Invalid Operation Exception is thrown at line 25.
You need to correct the code so that the call from the service back to the client completes successfully.
What are two possible ways to achieve this goal (Each correct answer presents a complete solution. Choose two.)
A.Change the service contract definition in line 01 as follows. [ServiceContract(CallbackContract = typeof(INameService), SessionMode = SessionMode.Required)] B.Add the following attribute to the NameService class, before line 40.
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)] C.Add the following attribute to the GreetingService class, before line 20. [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)] D.Add the following attribute to the GreetingService class, before line 20. [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]

Answer: CD
QUESTION 44
A Windows Communication Foundation (WCF) service has the following contract.
[ServiceContract] public class ContosoService { [OperationContract] [TransactionFlow(TransactionFlowOption.Mandatory)] [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = false)] void TxOp1(string value) { ... } [OperationContract(IsTerminating=true)] [TransactionFlow(TransactionFlowOption.Mandatory)] [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = false)] void TxOp2(string value) {

... OperationContext.Current.SetTransactionComplete(); } }
The service and the clients that call the service use NetTcpBinding with transaction flow enabled. You need to configure the service so that when TxOp1 and TxOp2 are invoked under the same client session, they run under the same transaction context.
What should you do?
A. Update the service contract to read as follows. [ServiceContract(SessionMode = SessionMode.Required)] Add the following behavior to the service implementation. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
B. Update the service contract to read as follows. [ServiceContract(SessionMode = SessionMode.Allowed)] Add the following behavior to the service implementation. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ReleaseServiceInstanceOnTransactionComplete = false)]
C. Update the service contract to read as follows. [ServiceContract(SessionMode = SessionMode.Allowed)] Add the following behavior to the service implementation. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
D. Update the service contract to read as follows. [ServiceContract(SessionMode = SessionMode.Required)] Add the following behavior to the service implementation. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]

Answer: A
QUESTION 45
You are creating a Window Communication Foundation (WCF) service application. The application needs to service many clients and requests simultaneously. The application also needs to ensure subsequent individual client requests provide a stateful conversation. You need to configure the service to support these requirements.
Which attribute should you add to the class that is implementing the service?
A. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,

ConcurrencyMode = ConcurrencyMode.Single)]
B. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Reentrant)]
C. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]
D. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]

Answer: C
QUESTION 46
You are integrating a Windows Communication Foundation (WCF) service within an enterprise-wide Service
Oriented Architecture (SOA). Your service has the following service contract.
[ServiceContract]
public class CreditCardConfirmationService
{
[OperationContract]
public Boolean ConfirmCreditCard(string ccNumber
double orderAmount, int orderNumber)
{
...
}
}
You need to allow the code in the ConfirmCreditCard method to participate automatically in existing transactions. If there is no existing transaction, a new transaction must be created automatically.
What should you do?
A.Inside the ConfirmCreditCard method, surround the code that must participate in the transaction with a using(new TransactionScope()) block.
B.Inside the ConfirmCreditCard method, surround the code that must participate in the transaction with a using(new CommittableTransaction()) block.
C.Add an [OperationBehavior(TransactionScopeRequired = true)] attribute to the ConfirmCreditCard method.
D.Add an [OperationBehavior(TransactionAutoComplete = true)] attribute to the ConfirmCreditCard method.
Answer: C

QUESTION 47
Your Windows Communication Foundation (WCF) client application uses HTTP to communicate with the service.
You need to enable message logging and include all security information such as tokens and nonces in logged messages.
What should you do?
A.In the application configuration file, add the logKnownPii attribute to the message logging diagnostics source and set the value of the attribute to true. Generate the ContosoService class using the Add Service Reference wizard. Add a reference to System.ServiceModel.Routing.dll. Add the following code segment. ContosoService client = new ContosoService(); SoapProcessingBehavior behavior = new SoapProcessingBehavior(); behavior.ProcessMessages = true; client.Endpoint.Behaviors.Add(behavior);
B.In the application configuration file, add the following XML segment to the system.serviceModel configuration section group.

In the machine configuration file, add the following XML segment to the system.serviceModel configuration section.

Generate the ContosoService class using the Add Service Reference wizard. Add the following code segment. ContosoService client = new ContosoService(); client.Endpoint.Behaviors.Add(new CallbackDebugBehavior(true));
C.In the machine configuration file, add the following XML segment to the system.serviceModel configuration section.

In the application configuration file, add the logKnownPii attribute to the message logging diagnostics source and set the value of the attribute to true. D.In the application configuration file, add the following XML segment to the system.serviceModel configuration section group.




Answer: D
QUESTION 48
A Windows Communication Foundation (WCF) service has the following contract.
[ServiceContract(Namespace="http://contoso.com")] public interface IShipping {
[OperationContract] string DoWork(int id); }
This is one of several service contracts hosted by your application. All endpoints use SOAP 1.2 bindings with WS-Addressing 1.0. The System.ServiceModel.MessageLogging trace source in the system.diagnostics configuration section is configured with one listener. You need to make sure that only the messages that are returned from the DoWork operation are logged.
Which XML segment should you add to the system.serviceModel/diagnostics/messageLogging/filters configuration element?
A.
//addr:Action[text()='http://contoso.com/IShipping/DoWorkResponse']

B.
//soap:Action[text()='http://contoso.com/IShipping/DoWorkResponse']

C.
//addr:Action[text()='http://contoso.com/IShipping/DoWork']

D.
//soap:Action[text()='http://contoso.com/IShipping/DoWork']


Answer: A
QUESTION 49
You are implementing a Windows Communication Foundation (WCF) service contract named IContosoService in a class named ContosoService. The service occasionally fails due to an exception being thrown at the service. You need to send the stack trace of any unhandled exceptions to clients as a fault message.

What should you do?
A.In the application configuration file on the client, add the following XML segment to the system.serviceModel/behaviors configuration section group.

Associate the debug behavior with any endpoints that need to return exception details.
B.In the application configuration file on the service and all the clients, add the following XML segment to the system.diagnostics/sources configuration section group.

C.Apply the following attribute to the ContosoService class. [ServiceBehavior(IncludeExceptionDetailInFaults = true)] D.For each OperationContract exposed by IcontosoService, apply the following attribute. [FaultContract(typeof(Exception))]

Answer: C
QUESTION 50
A Windows Communication Foundation (WCF) service is generating a separate namespace declaration for each body member of a message contract, even though all body members share the same namespace. You need to simplify the XML representation of your message contract so that the namespace is only declared once.
What should you do?
A.Declare a wrapper namespace for the message contract by using the WrapperNamespace property of the MessageContract attribute. B.Explicitly set the Namespace property of all the MessageBodyMember attributes to the same namespace. C.Declare all the body members as properties of a DataContract class and use the class as the only body member of the message contract. D.Declare all of the body members as properties of a separate MessageContract class and use the class as the only body member of the message contract.


Answer: C
QUESTION 51
You are developing a Windows Communication Foundation (WCF) service. You write a method named Submit that accepts messages of the type System.ServiceModel.Channels.Message.
You need to process the body of the incoming messages multiple times in the method.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Use the GetBody method of the Message class to read the content of the messages.
B. Use the CreateBufferedCopy method of the Message class to load the messages into memory.
C. Use the WriteBodyContents method of the BodyWriter class to make a copy of the messages.
D. Use the CreateMessage method of the MessageBuffer class to make a copy of the messages.

Answer: BD
QUESTION 52
You are creating a Windows Communication Foundation (WCF) service that responds using plain-old XML (POX).
You have the following requirements:
��You must enable the /catalog.svc/items operation to respond using the POX, JSON, or ATOM formats. You also must ensure that the same URL is used regardless of the result type. ��You must determine the response format by using the Accepts HTTP header.
What should you do?
A.Implement the IChannelInitializer interface in the service class. B.Implement the System.Runtime.Serialization.IFormatterConverter interface in the service class. C.Set the BodyStyle parameter of the WebGet attribute on the operation to
WebMessageBodyStyle.WrappedResponse. D.Set the return type of the operation to System.ServiceModel.Channels.Message. Use the current WebOperationContext methods to return the data in the required format.
Answer: D
QUESTION 53

A Windows Communication Foundation (WCF) solution uses two services to manage a shopping cart. Service A processes messages containing line items that total between $0 and $500. Service B processes messages containing line items that total more than $500. All messages are of equal importance to the business logic. You need to route incoming messages to the appropriate services by using WCF routing.
Which two message filters should you add to the router? (Each correct answer presents part of the solution. Choose two.)
A.a message filter with a priority of 100 that will forward messages that total between $0 and $500 to Service A
B.a message filter with a priority of 0 that will forward messages that total between $0 and $500 to Service A
C.a message filter with a priority of 0 that will forward all messages to Service B
D.a message filter with a priority of 100 that will forward all messages to Service B

Answer: AC
QUESTION 54
You have an existing Windows Communication Foundation (WCF) service.
You need to ensure that other services are notified when the service is started.
What should you do?
A. Add the following standard endpoint to the service.
B. Add the following standard endpoint to the service.
C. Add a service behavior with the following element.

D. Add a service behavior with the following element.

Answer: D QUESTION 55

You are developing a Windows Communication Foundation (WCF) service that reads messages from a public non-transactional MSMQ queue. You need to configure the service to read messages from the failed-delivery queue.
Which URI should you specify in the endpoint configuration settings of the service?
A. net.msmq://localhost/msmq$;FailedMessages
B. net.msmq://localhost/msmq$;DeadLetter
C. net.msmq://localhost/system$;DeadXact
D. net.msmq://localhost/system$;DeadLetter

Answer: D
QUESTION 56
You have an existing Windows Communication Foundation (WCF) service that exposes a service contract over HTTP. You need to expose that contract over HTTP and TCP.
What should you do?
A. Add a net.tcp base address to the host.
B. Add an endpoint configured with a netTcpBinding.
C. Add an endpoint behavior named netTcpBehavior to the existing endpoint.
D. Add a binding configuration to the existing endpoint named netTcpBinding.

Answer: B
QUESTION 57
You have an existing Windows Communication Foundation (WCF) Web service. The Web service is not responding to messages larger than 64 KB.
You need to ensure that the Web service can accept messages larger than 64 KB without generating errors.
What should you do?
A. Increase the value of maxReceivedMessageSize on the endpoint binding.
B. Increase the value of maxRequestLength on the httpRuntime element.
C. Increase the value of maxBufferSize on the endpoint binding.
D. Increase the value of maxBufferPoolSize on the endpoint binding.
Answer: A QUESTION 58

A Windows Communication Foundation (WCF) service is responsible for transmitting XML documents between systems.
The service has the following requirements:
It must minimize the transmission size by attaching the XML document as is without using escape characters or base64 encoding. It must interoperate with systems that use SOAP but are not built on the .NET platform.
You need to configure the service to support these requirements.
Which message encoding should you use?
A. Binary message encoding
B. MTOM (Message Transmission Optimization Mechanism) message encoding
C. Text message encoding with message version set to none
D. Text message encoding with message version set to SOAP 1.2

Answer: B
QUESTION 59
You are adding a Windows Communication Foundation (WCF) service to an existing application. The application is configured as follows. (Line numbers are included for reference only.)
01 02 03 04 06 07 08 09 10 11 12 13 14 15

16
17
18
...
You need to configure the service to publish the service metadata.
Which two actions should you perform? (Each correct answer presents part of the solution. (Choose two.)
A. Add the following XML segment between lines 10 and 11.
B. Add the following XML segment between lines 10 and 11.
C. Add the following XML segment between lines 15 and 16.

D. Add the following XML segment between lines 15 and 16

Answer: AD
QUESTION 60
Four Windows Communication Foundation (WCF) services are hosted in Microsoft Internet Information Services (IIS). No behavior configuration exists in the web.config file. You need to configure the application so that every service and endpoint limits the number of concurrent calls to 50 and the number of concurrent sessions to 25.
Which XML segment should you add to the system.serviceModel configuration section of the web.config file?
A.

B.


C.

D.


Answer: C
QUESTION 61
Windows Communication Foundation (WCF) service is self-hosted in a console application. The service implements the ITimeService service interface in the TimeService class.
You need to configure the service endpoint for HTTP communication.
How should you define the service and endpoint tags?
A. Define the service tag as follows. Define the endpoint tag as follows.
B. Define the service tag as follows. Define the endpoint tag as follows.
binding="wsHttpBinding" contract="ITimeService"/>
C. Define the service tag as follows. Define the endpoint tag as follows.
D. Define the service tag as follows. Define the endpoint tag as follows.

Answer: D
QUESTION 62
Windows Communication Foundation (WCF) service will be hosted in Microsoft Internet Information Services (IIS). You create a new application in IIS to host this service and copy the service DLL to the bin directory of the application. You need to complete the deployment of this service to IIS.
What should you do next?
A.Create an .asmx file and add a @ServiceHost directive to this file. Copy the file to the root of the application directory. B.Create an .asmx file and add a @Register directive to this file. Copy the file to the bin directory of the application. C.Create a .svc file and add a @ServiceHost directive to this file. Copy the file to the root of the application directory. D.Create a .svc file and add a @Register directive to this file. Copy the file to the bin directory of the application.

Answer: C
QUESTION 63
You are developing a Windows Communication Foundation (WCF) service that will be hosted in Microsoft Internet Information Services (IIS) 7.0. The service must be hosted in an IIS application named Info. You need to enable this service to be hosted in IIS by changing the web.config file.

Which XML segment should you add to the web.config file?
A.

B.

C.

D.


Answer: A
QUESTION 64
You are creating a Windows Communication Foundation (WCF) service. You need to ensure that the service is compatible with ASP.NET to make use of the session state.
Which binding should you use?
A. NetTcpContextBinding
B. BasicHttpContextBinding
C. NetTcpBinding
D. NetMsmqBinding

Answer: C
QUESTION 65
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

Answer: B
QUESTION 66
An ASP.NET application hosts a RESTful Windows Communication Foundation (WCF) service at /Services/Contoso.svc. The service provides a JavaScript resource to clients. You have an explicit reference to the JavaScript in your page markup as follows.