Translate

Thursday, August 30, 2012

what are the advantages of hosting WCF Services in IIS as compared to self-hosting?

There are two main advantages of using IIS over self-hosting:-
Automatic activation
IIS provides automatic activation that means the service is not necessary to be running in
advance. When any message is received by the service it then launches and fulfills the request.
But in case of self hosting the service should always be running.
Process recycling
If IIS finds that a service is not healthy that means if it has memory leaks etc, IIS recycles the
process. For every browser instance, a
worker process is spawned and the request is serviced. When the browser disconnects the worker,
process stops and you loose all information. IIS also restarts the worker process. By default, the
worker process is recycled at around 120 minutes. So why does IIS recycle. By restarting the
worker process it ensures any bad code or memory leak do not cause issue to the whole system.
In case of self-hosting both the above features, you will need to code yourself. Lot of work
right!!.

How to generate proxy for WCF Services?

The proxy can be generated using Visual Studio by right clicking Reference and clicking on Add Service Reference. This brings up the Add Service Reference dialog box, where you need to supply the base address of the service (or a base address and a MEX URI) and the namespace to contain the proxy.
Proxy can also be generated by using SvcUtil.exe command-line utility. We need to provide SvcUtil with the HTTP-GET address or the metadata exchange endpoint address and, optionally, with a proxy filename. The default proxy filename is output.cs but you can also use the /out switch to indicate a different name.
SvcUtil http://localhost/MyService/MyService.svc /out:Proxy.cs
When we are hosting in IIS and selecting a port other than port 80 (such as port 88), we must provide that port number as part of the base address:
SvcUtil http://localhost:88/MyService/MyService.svc /out:Proxy.cs

What are SOAP Faults in WCF?

Common language runtime (CLR) exceptions do not flow across service boundaries. At the maximum, a CLR exceptions may propagate up to the service tier from business components. Unhandled CLR exceptions reach the service channel and are serialized as SOAP faults before reporting to clients. An unhandled CLR exception will fault the service channel, taking any existing sessions with it. That is why it is very importatnt to convert the CLR exceptions into SOAP faults. Where possible, throw fault exceptions

What is the proxy for WCF Service?

A proxy is a class by which a service client can Interact with the service.
By the use of proxy in the client application we are able to call the different methods exposed by the service

What are the types of contract available in WCF?

The main contracts are:
a)Service Contract:Describes what operations the client can perform.
b)Operation Contract : defines the method inside Interface of Service.
c)Data Contract:Defines what data types are passed
d)Message Contract:Defines wheather a service can interact directly with messages

In WCF which bindings supports the reliable session?

In WCF, following bindings supports the reliable session - 

1. wsHttpBinding 
2. wsDualHttpBinding 
3. wsFederationHttpBinding 
4. netTcpBinding 

What are the advantages of hosting WCF service in WAS?

WAS (Windows Activation Service) is a component of IIS 7.0. Following are few advantages : 

1. We are not only limited to HTTP protocol. We can also use supported protocols like TCP, named pipes and MSMQ 

2. No need to completely install IIS. We can only install WAS component and keep away the WebServer. 

What is service host factory in WCF?

1. Service host factory is the mechanism by which we can create the instances of service host dynamically as the request comes in. 
2. This is useful when we need to implement the event handlers for opening and closing the service. 
3. WCF provides ServiceFactory class for this purpose. 

What are the core security features that WCF addresses?

There are four core security features that WCF addresses:-

Confidentiality: This feature ensures that the information does not go in wrong hands when it travels from the sender to the receiver.

Integrity: This feature ensures that the receiver of the message gets the same information that the sender sends without any data tampering. 

Authentication: This feature verifies who the sender is and who the receiver is. 

Authorization: This feature verifies whether the user is authorized to perform the action they are requesting from the application.


What the different transaction options ?

There are three transaction option in wcf :

TransactionFlowOption.NotAllowed

This is a default option. Using this option no transaction will be propagated across the binding. If any client attempts to call the WCF service in a transaction it will be ignored for this option.

TransactionFlowOption.Allowed

This option specifies that client can call this WCF service in a transaction. It’s not compulsory that the service needs to be called in a transaction. You can call without the transaction also.

TransactionFlowOption.Mandatory

This option specifies that client must call the WCF service in a transaction mode. If the WCF service is called without transaction, ‘FaultException’ will be raised.

What are the major differences between services and Web services? OR What is the difference WCF and Web services?

Web services can only be invoked by HTTP. While Service or a WCF component can be invoked by any protocol and any transport type. Second web services are not flexible. However, Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.

What is wcf ?

The Windows Communication Foundation (or WCF), previously known as "Indigo", is a runtime and a set of APIs (application programming interface) in the .NET Framework for building connected, service-oriented applications.


What are ends, contracts, address and bindings?


• Contract (What)Contract is an agreement between two or more parties. It defines the protocol how client should communicate with your service. Technically, it describes parameters and return values for a method.
 

• Address (Where)An Address indicates where we can find this service. Address is a URL, which points to the location of the service.
 

• Binding (How)Bindings determine how this end can be accessed. It determines how communications is done. For instance, you expose your service, which can be accessed using SOAP over HTTP or BINARY over TCP. So for each of these communications medium two bindings will be created.
Below figure, show the three main components of end. You can see the stock ticker is the service class, which has an end hosted on www.soa.com with HTTP and TCP binding support and using Stock Ticker interface type.
 

constructor chaining

where a constructor calls another constructor in its class using the ": this()" designation as 


public Test( bool a, int b, string c )
    : this( a, b )
{
    this.m_C = c;
}
public Test( bool a, int b, float d )
    : this( a, b )
{
    this.m_D = d;
}
private Test( bool a, int b )
{
    this.m_A = a;
    this.m_B = b;
}

Basically constructor chaining is where a subclass calls its superclasses constructor which subsequentally calls its superclasses constrctor and so on.

Difference between # and ## in sql server ?


#table refers to a local (visible to only the user who created it) temporary table.

##table refers to a global (visible to all users) temporary table.