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 IGreetingService03 {04 [OperationContract]05 string GetMessage();06 }07 [ServiceContract]08 public interface INameService09 {10 [OperationContract]11 string GetName();12 }The code that implements the IGreetingService interface is as follows:20 public class GreetingService : IGreetingService21{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 lNameService interface is as follows:40 class NameService : INameService41 {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 InvalidOperationException 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 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 lNameService 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 InvalidOperationException 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.)()


相关考题:

● (75) has become a fact of modern life, with millions of people now shopping on-line.(75)A. E-mailB. E-commerceC. E-learningD. E-communication

胭脂的英文是Rouge/foundation(blush)() 此题为判断题(对,错)。

You’re going to have a quiz ( )by another two in the ( )month. A. followed,followedB. followed,followingC. following,followedD. following,following

在播放视屏时,需要保持屏幕一直亮着,需要哪个权限?() A.uses-permission android:name="android.permission.INTERNET"/B.uses-permission android:name="android.permission.WAKE_LOCK"/C.uses-permission android:name="android.permission.SCREEN_LOCK"/D.uses-permission android:name="android.permission.DIM_LOCK"/

( )has become a fact of modern life,with millions of people now shopping on-line.A.E-mailB.E-commerceC.E-learningD.E-communication

以下属于调用摄像头硬件的权限的是:()A.<uses-permission android:name="android.permission.CAMERA"/>B.<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />C.<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>D.<uses-permission android:name="android.permission.INTERNET"/>

3、注册一个短信到来的广播事件需要在清单文件配置什么权限()A.<uses-permission android:name="android.permission.SMS"/>B.<uses-permission android:name="android.permission.SEND_SMS"/>C.<uses-permission android:name="android.permission.RECEIVE_SMS"/>D.<uses-permission android:name="android.permission.RECEIVE_SEND_SMS"/>

下面哪个是添加网络权限的代码A.<uses-permission android:name="android.permission.INTERNET"/>B.<uses-permission android:name="android.permission.ACCEPT_HANDOVER"/>C.<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>D.<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

注册一个短信到来的广播事件需要在清单文件配置什么权限()A.<uses-permission android:name="android.permission.SMS"/>B.<uses-permission android:name="android.permission.SEND_SMS"/>C.<uses-permission android:name="android.permission.RECEIVE_SMS"/>D.<uses-permission android:name="android.permission.RECEIVE_SEND_SMS"/>

注册一个短信到来的广播事件需要在清单文件配置什么权限()。A.<uses-permission android:name="android.permission.SMS"/>B.<uses-permission android:name="android.permission.SEND_SMS"/>C.<uses-permission android:name="android.permission.RECEIVE_SMS"/>D.<uses-permission android:name="android.permission.RECEIVE_SEND_SMS"/>