Which code segment should you use?

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?

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
{
[Operation Contract(Action=”Sum”)]
public int Add(int x, int y)
{}
}

B.
[ServiceContract(ConfigurationName=”Arithmetic”)]
public class Calculator
{
[Operation Contract(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)
{}
}

Explanation:
Name Gets or sets the name for the <portType> element in Web Services Description Language (WSDL). (<- ServiceContract)
Name Gets or sets the name of the operation. (<-OperationContract)

ServiceContractAttribute Class
(http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.aspx)

OperationContractAttribute Class
(http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.aspx)



Leave a Reply 2

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


discount elliptical trainer

discount elliptical trainer

Impressive site. Plenty of beneficial info the following. I am just transmitting the idea to a number of pals ans as well spreading around scrumptious. Not to mention, appreciate it in your work!