Tuesday, May 7, 2013

Web Services & WCF

1.What is Service behavior?


•The Service Behavior defines how the endpoint interacts with clients. Attributes like security, concurrency, caching, logging, etc. - those are all part of the behavior.

2.How do you overload in WCF

[OperationContract(Name = "GetIntegerData")]
string GetData(int value);


[OperationContract(Name = "GetStringData")]
string GetData(string value);

3.WCF concurrency modes?

1.Single
2.Multiple
3.Reentraint


WCF throttling helps you to put an upper limit on the number of concurrent calls, WCF instances, and concurrent sessions. WCF provides three ways by which you can define upper limits: MaxConcurrentCalls, MaxConcurrentInstances, and MaxConcurrentSessions.

Below is a simple table which shows the default settings for throttling for different WCF versions:

MaxConcurrentSessionsMaxConcurrentCalls MaxConcurrentInstances 
WCF 3.0 / 3.562610
WCF 4.016 * processorcount MaxConcurrentCallsMaxConcurrentCalls
+
MaxConcurrentSessions 100 * processorcount


100 * processorcount


4. What is the difference between WCF and ASMX Web Services?

Simple and basic difference is that ASMX or ASP.NET web service is designed to send and receive messages using SOAP over HTTP only.

While WCF can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, NamedPipes etc).

5.What are the possible ways of hosting a WCF service? Explain?

For a Windows Communication Foundation service to host, we need at least a managed process, a ServiceHost instance and an Endpoint configured. Possible approaches for hosting a service are:
  1. Hosting in a Managed Application/ Self Hosting
    1. Console Application
    2. Windows Application
    3. Windows Service
  2. Hosting on Web Server
    1. IIS 6.0 (ASP.NET Application supports only HTTP)
    2. Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP, NamedPipes, MSMQ.
6. What is WSDL and Disco files? 
WSDL is specification defining how to describe web service in a common XML grammar.
a) Interface information describing all publicly available functions.
b) Data type information for all messages requests and message responses.
c) Binding information about the transport protocol to be used.
d) Address information for locating the specified service web service transport protocol HTTP,SMTP,FTP
XML Messaging protocol-Encodes message in a common XML ,SOAP
(service) Description protocol: used to describe the public interfaces to a specific web service.
(service) Discovery protocol:
In most cases the protocol used in SOAP.
7.What is remoting?

In brief, .NET remoting is an architecture which enables communication between different application domains or processes using different transportation protocols, serialization formats, object lifetime schemes, and modes of object creation. Remote means any object which executes outside the application domain. The two processes can exist on the same computer or on two computers connected by a LAN or the Internet. This is called marshalling (This is the process of passing parameters from one context to another.), and there are two basic ways to marshal an object:

Marshal by value: the server creates a copy of the object passes the copy to the client.

Marshal by reference: the client creates a proxy for the object and then uses the proxy to access the object.

protocols used in remoting http and tcp
wcf along with named pipes and msmg

wcf is faster than remoting

8.WCF Security?

Transport Security Mode Authentication Options

The follow authentication options are available when using transport security mode:
  • None. When using this option, the WCF service does not authenticate the callers. This is not the recommended option from a security perspective–avoid using this option wherever possible.
  • Basic. This option is available with the HTTP protocol only. The client is authenticated using the username and password against Active Directory. The client credentials are transported using the Base64 encode string, which is literally like a clear string and therefore is not the most secure option. The service is authenticated by the SSL certificate used for secure communication.
  • NTLM. This option is available with the HTTP protocol only. The client is authenticated using a challenge-response scheme against Windows accounts. The NTLM option is well suited for a workgroup environment. NTLM authentication is more secure than either Digest or Basic authentication. The service is authenticated using the Windows credentials of the process identity or using an SSL certificate if you are using the HTTP protocol.
  • Windows. The Windows option tells the WCF service to use Kerberos when in a domain, or NTLM when deployed in a workgroup environment. This option uses a Windows token presented by the caller to authenticate against Active Directory. This is the most secure option compared to Basic, Digest, or NTLM authentication. The service is authenticated using the Windows credentials of the process identity or an SSL certificate if you are using the HTTP protocol.
  • Certificate. When using this option, the caller presents an X.509 client certificate that the WCF service either validates with peer trust or trusts based on the issuer of the certificate. This option should be used when Windows authentication is not possible, as in the case of business-to-business (B2B) scenarios. The service is authenticated with the service certificate or by using an SSL certificate if you are using the HTTP protocol.

Message Security Mode Authentication Options

The follow authentication options are available when using message security mode:
  • None. When using this option, the WCF service does not authenticate the callers. This is not the recommended option from a security perspective–avoid using this option wherever possible.
  • Windows. When using this option, the WCF service uses Kerberos when in a domain, or NTLM when deployed in a workgroup environment. This option uses the Windows token presented by the caller in order to authenticate against the Active Directory. The service is authenticated using the Windows credentials of the process identity.
  • Username. When using this option, the caller provides the username and password to the service. The service can authenticate against Windows, use membership providers such as SqlMembershipProvider, or use a custom validator to validate against the custom store. You should choose this option only when Windows authentication is not possible. The service is authenticated with a service certificate.
  • Certificate. When using this option, the caller presents an X.509 client certificate; the WCF service then looks up the certificate information on the host side and either validates it (peer trust) or trusts the issuer (chain trust) of the client certificate. This option should be used when Windows authentication is not possible, or in B2B scenarios. Service is authenticated with a service certificate.
  • Issue token. When using this option, the client and service depend on a secure token service (STS) to issue tokens that the client and service trusts. Microsoft Windows CardSpace™ is a typical example of an STS.
9. WCF Binding?

For example, you should go for basicHttpBinding or wsHttpBinding, if interoperability is your concern and you need to communicate with non-WCF systems. In some case, your service can reside on a single system, In such scenario netNamedPipeBinding will be the most efficient option. netTcpBinding or netPeerTcpBinding might be best options, if you need to communicate across multiple computers.And if the service needs support for disconnected or queued calls, netMsmqBinding or msmqIntegrationBinding will be the candidate options.

10. WCF?

http://www.codemag.com/article/0611051

11.What are the protocols used in web service?

1.XML
2.SOAP,
3.JSON
4.REST.

12. What is the difference between POST and PUT?

POST-Used to modify and update a resource

PUT-Used to create a resource, or overwrite it. While you specify the resources new URL.

13. What are the endpoints?
A Service Endpoint has an Address, a Binding, and a Contract.

14.Huge data we need to transfer which protocol we need to use?
using basichttpbinding by streaming.NetTcpBinding, and NetNamedPipeBinding

15. Difference between wcf service and web services?

Features Web Service WCF
Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service
Programming [WebService] attribute has to be added to the class [ServiceContraact] attribute has to be added to the class
Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client
Operation One-way, Request- Response are the different operations supported in web service One-Way, Request-Response, Duplex are different type of operations supported in WCF
XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespace is used for serialization
Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom XML 1.0, MTOM, Binary, Custom
Transports Can be accessed through HTTP, TCP, Custom Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
Protocols Security Security, Reliable messaging, Transactions















No comments:

Post a Comment