Showing posts with label wcf. Show all posts
Showing posts with label wcf. Show all posts

Webservice ,Remoting,XSLT Interview Questions


Q1)Define XMLReader Class and XMLValidatingReader class?
Ans)

The XMLReader Class (Assembly: System.Xml.dll) represents a reader that provides fast, non-cached, forward-only access to XML data.

The XMLValidatingReader class (Assembly: System.Xml.dll) represents a reader that provides:
a) Document type definition (DTD),
b) XML-Data Reduced (XDR) schema, and
c) XML Schema definition language (XSD) validation
---------------------------------------------
Q2)Are Web services only written in .NET ?
Answer:

No.....

A web service is based on SOAP (Simple Object Access Protocol). So any technology which is able to implement SOAP should be able to create a web service. For example we can create web services in .NET or Java.

Tags: web services, wcf

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

WCF Interview Questions Part_2

Previous Questions                                                                                 Next Questions

4)      What are the main components of WCF?
Ans)
            The main components of WCF are

1. Service class
2. Hosting environment
3. End point
----------------------------------------------------
5)      Can you explain how End points, Contract, Address and Bindings are done in WCF?
Ans)
All communication with a Windows Communication Foundation (WCF) service occurs through the endpoints of the service. Endpoints provide clients access to the functionality offered by a WCF service.
            Each endpoint consists of four properties:
ñ An address that indicates where the endpoint can be found.
ñ A binding that specifies how a client can communicate with the endpoint.
ñ A contract that identifies the operations available.
ñ A set of behaviors that specify local implementation details of the endpoint.
Example for Create EndPoints:
This example we explain with TCP Binding  binding type & class for this one is NetTcpBinding
string urlService=  “HostName”;
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel =                             System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial
                
 // Add a endpoint
syntax :: host.AddServiceEndpoint(contract,Binding,Address)
host.AddServiceEndpoint(typeof(Method or class for access your service), tcpBinding, urlService);

-------------------------------------
6)What is a service class?
Ans) Service class means a .cs file, it contains the Servicecontract,DataContract & Operationcontract.
Service class is contains Endpoints.


Previous Questions                                                            Next Questions

WCF Interview Questions Part_1

1)What is WCF?

First let us give a short answer to this: - “WCF (Indigo was the code name for WCF) is a unification of .NET framework communication technologies “.WCF is a unification technology, which unites the following technologies:-
• NET remoting
• MSMQ
• Web services
• COM+.
Below figure depicts WCF fundamentals pictorially.


---------------------------------------------------------------------

2)What are bindings?
Ans)
Bindings specify how a Windows Communication Foundation (WCF) service endpoint communicates with other endpoints. At its most basic, a binding must specify the transport (for example, HTTP or TCP) to use. You can also set other characteristics, such as security and transaction support, through bindings.
Here we have 9 types of binidings and this binding classes are under the
System.ServiceModel namespase
Binding type
Class name under  “System.ServiceModel” namespase

Basic Binding

BasicHttpBinding

TCP Binding

NetTcpBinding

Peer Network Binding

NetPeerTcpBinding 

IPC Binding

NetNamedPipeBinding

Web Service (WS)  Binding

WSHttpBinding

Federated WS Binding

WSFederationHttpBinding

Duplex WS Binding

WSDualHttpBinding

MSMQ Binding

NetMsmqBinding

MSMQ Integration Binding

MsmqIntegrationBinding



-------------------------------------------------------------------------------------------------------

3)      Which specifications does WCF follow?
Ans)

WCF supports specifications defined by WS-* specifications. WS-* specifications are defined together by Microsoft, IBM, SUN and many other big companies so that they can expose there service through a common protocol. WCF supports all specifications defined we will understand them one by one.

1.Messaging (WS-Addressing):- SOAP is the fundamental protocol for web services. WS Addressing defines some extra additions to SOAP headers, which makes SOAP free from underlying transport protocol. One of the good things about Message transmission is MTOM, also termed as Message Transmission Optimization Mechanism. They optimize transmission format for SOAP messages in XML-Binary formant using XML optimized packaging (XOP). Because the data will sent in binary and optimized format, it will give us huge performance gain.

2.Security (WS-Security, WS-Trust, and WS-Secure Conversation): - All the three WS- define authentication, security, data integrity and privacy features for a service.

3.Reliability (WS-Reliable Messaging): - This specification ensures end-to-end communication when we want SOAP messages to be traversed back and forth many times.

4.Transactions (WS-Coordination and WS-Atomic Transaction): - These two specifications enable transaction with SOAP messages.

5.Metadata (WS-Policy and WS-Metadata exchange): - WSDL is a implementation of WS-Metadata Exchange protocol. WS-Policy defines more dynamic features of a service, which cannot be expressed by WSDL.
We have stressed on the WS-* specification as it is a specification which a service has to follow to be compatible with other languages. Because WCF follows WS-* specifications other languages like JAVA , C++ can also exploit features like Messaging , Security , Reliability and transactions written in C# or VB.NET. This is the biggest achievement of WCF to integrate the above features with other languages.