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

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 follows. <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?

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 follows. <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>(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); }

B.
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); }

C.
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); }

D.
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); }

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *