Interview Question and Answers WCF-8

What is service and client in perspective of data communication?

A service is a unit of functionality exposed to the world. The client of a service is merely the party consuming the service.

1. A user has a service with a one-way operation that includes a fault contract, and he
gets an exception when he tries to host the service. Why?
This happens because, to return faults, the service needs some form of a two-way communication channel in place, which is not the case with one-way operations.

2. A user has a service he wants to expose on the Internet, and it needs to send notifications
out to its consumers. Would the WCF Duplex MEP be a good choice for
implementing this?
No. The WCF Duplex MEP can be problematic to enable, even inside an enterprise.
Its implementation depends upon the service establishing a connection back to the consumer, which can’t happen in certain scenarios, such as when the client’s machine uses NAT behind a firewall. On the Internet, where you are never certain
where your consumers are coming from, this type of callback channel would rarely, if ever, work. When you factor in the security risks it could pose and the scalability concerns with the fact that callback channels require the presence of sessions
between client and service, it isn’t a feasible solution.

3. You have a Data contract specifying a Person class from which you derive a Customer class. Does a Customer object automatically have a Data contract as well?
No. The Data contract is not inherited, so any derived class, such as the Customer class, would have to be explicitly declared as having a Data contract as well.

4. Your company has its own proprietary authentication mechanism, and you are required to authenticate every message coming into the service. What is the best way to handle using this mechanism with WCF?
Likely the best way to handle this would be to design a Message contract that accepts these proprietary authentication tokens in the header.

5. Can you support the Rpc SOAP style by using the DataContractSerializer?
Yes. You need only adorn your service with the DataContractFormatAttribute and explicitly set the attribute’s Style property to OperationFormatStyle.Rpc.

6. What does the “ABCs of endpoints” refer to?
The ABCs of endpoints refers to the three required elements that comprise a service endpoint: address, binding, and contract.

7. Which standard binding could be used for a service that was designed to replace an existing ASMX Web service?
The basicHttpBinding standard binding was designed to expose a service as if it were an ASMX Web service. This enables you to support existing clients as applications are upgraded to WCF.

8. What is the main disadvantage of using IIS to host a service?
Using IIS to host your services means that you will not be able to support non-HTTP protocols such as TCP, named pipes, and MSMQ. You will have access to the many built-in features available with IIS such as process recycling and messagebased

9. Which file specifies the types that your service will expose in IIS?
Service types are exposed through IIS by using the service file. This file must have an .svc file extension and should reside in the application directory for your IIS hosting application. This file will include an @ServiceHost directive, which specifies
the service name and language for the service code files. These files should be located in an App_Code subdirectory.

No comments: