[WebInvoke(UriTemplate = "/statuses/update.xml?

You are developing a Windows Communication Foundation (WCF) client application.
The client application contains the following code.

[ServiceContract]
public interface ISocialStatus
{
[OperationContract]
[WebInvoke(UriTemplate = “/statuses/update.xml?status-{text}”)]
void UpdateStatus(string text);
}
public class SocialClient : ClientBase<ISocialStatus>, ISocialStatus
{

}

The configuration file contains the following lines.

<system.serviceModel>
<client>
<endpoint name=”SocialClient” address=”http://contoso.com”
binding=”webHttpBinding” contract=”SocialApp.ISocialStatus”
bindingConfiguration=”BindingConfig” />
</client>
<bindings />
</system.serviceModel>

You need to ensure that the service is consumed. Which code segment should you use?

You are developing a Windows Communication Foundation (WCF) client application.
The client application contains the following code.

[ServiceContract]
public interface ISocialStatus
{
[OperationContract]
[WebInvoke(UriTemplate = “/statuses/update.xml?status-{text}”)]
void UpdateStatus(string text);
}
public class SocialClient : ClientBase<ISocialStatus>, ISocialStatus
{

}

The configuration file contains the following lines.

<system.serviceModel>
<client>
<endpoint name=”SocialClient” address=”http://contoso.com”
binding=”webHttpBinding” contract=”SocialApp.ISocialStatus”
bindingConfiguration=”BindingConfig” />
</client>
<bindings />
</system.serviceModel>

You need to ensure that the service is consumed. Which code segment should you use?

A.
var client = new SocialClient(“SocialClient”);
client.Endpoint.Behaviors.Add(new WebHttpBehavior());

B.
var client = new SocialClient(“SocialClient”);
client.Endpoint.Behaviors.Add(new WebScriptEnablingBehovior());

C.
var client = new SocialClient(“POST”);
client.Endpoint.Behaviors.Add(new WebHttpBehovior());

D.
var client = new SocialClient(“POST”);
client.Endpoint.Behaviors.Add(new WebScriptEnablingBehavior());

Explanation:
ClientBase<TChannel> Class
(http://msdn.microsoft.com/en-us/library/ms576141.aspx)

ClientBase<TChannel> Class
Provides the base implementation used to create client objects that can call services.

Example:

public partial class SampleServiceClient : System.ServiceModel.ClientBase<ISampleService>, ISampleService
{

public SampleServiceClient()
{
}

public SampleServiceClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}

public SampleServiceClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}

public SampleServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}

public SampleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}

public string SampleMethod(string msg)
{
return base.Channel.SampleMethod(msg);
}
}



Leave a Reply 1

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