WCF Interview Questions Part_3

Previous Questions

7) What is a service contract, operation contract and Data Contract?
Ans)
ServiceContract :
Describes which operation client can perform on the services
Indicates that an interface or a class defines a service contract in a application
operation contract:
Indicates that a method defines an operation that is pBoldart of a service contract
Data Contract :
Defines which data type are processed to and from the services, It provides built in contract for implicit type
----------------------------------------------------
8)In WCF, "wsHttpBinding" uses plain unencrypted texts when transmitting messages and is backward compatible with traditional ASP.NET web services (ASMX Web Services) ?
Ans)
Select from following answers:

True
False
Not Aware

False

"wsHttpBinding" is secure (messages are encrypted while being transmitted), and transaction-aware. However, because this is a WS-* standard, some existing applications (for example: a QA tool) may not be able to consume this service. Hence, it is not completely backward compatible.
------------------------------------------
9) Why in WCF, the "httpGetEnabled" attribute is essential ?
Ans)

The attribute "httpGetEnabled" is essential because we want other applications to be able to locate the metadata of this service that we are hosting.


Without the metadata, client applications can't generate the proxy and thus won't be able to use the service.
-------------------------------------------
10)What is the purpose of base address in WCF service? How it is specified?
Ans)
When multiple endpoints are associated with WCF service, base address (one primary address) is assigned to the service, and relative addresses are assigned to each endpoint. Base address is specified in element for each service.
E.g.
```````````````````````````````````````````````````

























````````````````````````````````````````````````````
-------------------------------------------
11)What is the difference between XMLSerializer and the DataContractSerializer?
Ans)
a.DataContractSerializer is the default serializer fot the WCF
b.DataContractSerializer is very fast.
c.DataContractSerializer is basically for very small, simple subset of the XML infoset.
d.XMLSerializer is used for complex schemas.
-------------------------------------------
12)What is Fault Contracts in WCF?
Ans)
Fault Contracts is the way to handle exceptions in WCF. The problem with exceptions is that those are technology specific and therefore cannot be passed to other end because of interoperability issue. (Means either from Client to Server or vice-versa). There must be another way representing the exception to support the interoperability. And here the SOAP Faults comes into the picture.

Soap faults are not specific to any particular technology and they are based on industry standards.

To support SOAP Faults WCF provides FaultException class. This class has two forms:

a. FaultException : to send untyped fault back to consumer
b. FaultException: to send typed fault data to the client

WCF service also provides FaultContract attribute so that developer can specify which fault can be sent by the operation (method). This attribute can be applied to operations only.

.NET Framework Interview questions
-----------------------------
Q4)What is break mode? What are the options to step through code?
Ans)
Break mode lets you to observe code line to line in order to locate error.

The VS.NET provides following options to step through code.
• Step Into
• Step Over
• Step Out
• Run To Cursor
• Set Next Statement

Previous Questions