wcf interview questions
Top wcf frequently asked interview questions
I am totally confused between WCF and ASMX web services. I have used a lot of web services in my earlier stage, and now there is this new thing introduced called WCF. I can still create WCF that function as a web service. I think there will be more stuff in WCF.
Can anyone provide me any article or difference between WCF and Web services such as which one to use and when?
Source: (StackOverflow)
When designing a REST API or service are there any established best practices for dealing with security (Authentication, Authorization, Identity Management) ?
When building a SOAP API you have WS-Security as a guide and much literature exists on the topic. I have found less information about securing REST endpoints.
While I understand REST intentionally does not have specifications analogous to WS-* I am hoping best practices or recommended patterns have emerged.
Any discussion or links to relevant documents would be very much appreciated.
If it matters, we would be using WCF with POX/JSON serialized messages for our REST API's/Services built using v3.5 of the .NET Framework.
Source: (StackOverflow)
I've spent a few months trying to grasp the concepts behind WCF and recently I've developed my first WCF service application.
I've struggled quite a bit to understand all the settings in the config file.
I am not convinced about the environment but it seems that you can do amazing stuff with it.
The other day I've found out that Microsoft has come out with a new thing called ASP.NET Web API.
For what I can read it's a RESTful framework, very easy to use and implement.
Now, I am trying to figure out what are the main differences between the 2 frameworks and if I should try and convert my old WCF service application with the new API.
Could someone, please, help me to understand the differences and usage of each?
Source: (StackOverflow)
I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:
Could not find default endpoint
element that references contract
'IMySOAPWebService' in the service
model client configuaration section.
This might be because no
configuaration file was found for your
application or because no end point
element matching this contract could
be found in the client element
Searching for this error tells me to use the full namespace in the contract. Here's my
app.config with full namespace:
<client>
<endpoint address="http://192.168.100.87:7001/soap/IMySOAPWebService"
binding="basicHttpBinding" bindingConfiguration="IMySOAPWebServicebinding"
contract="Fusion.DataExchange.Workflows.IMySOAPWebService" name="IMySOAPWebServicePort" />
</client>
I'm running XP local (I mention this because a number of Google hits mention win2k3)
The app.config is copied to app.exe.config, so that is also not the problem.
Any clues?
Source: (StackOverflow)
I have a WCF service that has been working perfectly, and something has changed and I don't know what.
I get this exception:
System.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
This is confusing because I am running .NET 4.0.
Where do I turn on IncludeExceptionDetailInFaults
? I'm battling to find it.
Source: (StackOverflow)
I hate MSDN's site for WCF RIA services. It does not say what it is, it only says what it does. It says what it can achieve but does not say why I need it.
For example:
"A common problem when developing an
n-tier RIA solution is coordinating
application logic between the middle
tier and the presentation tier".
Well, it does not mean much to me.
"RIA Services solves this problem by
providing framework components, tools,
and services that make the application
logic on the server available to the
RIA client without requiring you to
manually duplicate that programming
logic. You can create a RIA client
that is aware of business rules and
know that the client is automatically
updated with latest middle tier logic
every time that the solution is
re-compiled."
So does it download DLLs from server? Is it a metadata describing the rules for the data?
So what is it? Is it just a VS 2010 add-on for RAD? Or is it a technology on top of WCF or underneath it or what? Where does it live? With data, with server, what?
I appreciate if you can summarise this for me please.
Source: (StackOverflow)
I can't get to the bottom of this error, because when the debugger is attached, it does not seem to occur. Below is the code.
This is a WCF server in a Windows service. The method NotifySubscribers is called by the service whenever there is a data event (at random intervals, but not very often - about 800 times per day).
When a Windows Forms client subscribes, the subscriber ID is added to the subscribers dictionary, and when the client unsubscribes, it is deleted from the dictionary. The error happens when (or after) a client unsubscribes. It appears that the next time the NotifySubscribers() method is called, the foreach() loop fails with the error in the subject line. The method writes the error into the application log as shown in the code below. When a debugger is attached and a client unsubscribes, the code executes fine.
Do you see a problem with this code? Do I need to make the dictionary thread-safe?
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class SubscriptionServer : ISubscriptionServer
{
private static IDictionary<Guid, Subscriber> subscribers;
public SubscriptionServer()
{
subscribers = new Dictionary<Guid, Subscriber>();
}
public void NotifySubscribers(DataRecord sr)
{
foreach(Subscriber s in subscribers.Values)
{
try
{
s.Callback.SignalData(sr);
}
catch (Exception e)
{
DCS.WriteToApplicationLog(e.Message,
System.Diagnostics.EventLogEntryType.Error);
UnsubscribeEvent(s.ClientId);
}
}
}
public Guid SubscribeEvent(string clientDescription)
{
Subscriber subscriber = new Subscriber();
subscriber.Callback = OperationContext.Current.
GetCallbackChannel<IDCSCallback>();
subscribers.Add(subscriber.ClientId, subscriber);
return subscriber.ClientId;
}
public void UnsubscribeEvent(Guid clientId)
{
try
{
subscribers.Remove(clientId);
}
catch(Exception e)
{
System.Diagnostics.Debug.WriteLine("Unsubscribe Error " +
e.Message);
}
}
}
Source: (StackOverflow)
I have a WCF Service which returns 1000 records from database to the client. I have an ASP.NET WCF client (I have added service reference in asp.net web application project to consume WCF).
I get the following message when I run the client application:
The maximum message size quota for incoming messages (65536) has been
exceeded. To increase the quota, use
the MaxReceivedMessageSize property on
the appropriate binding element.
Any help? How to increase message size quota?
Source: (StackOverflow)
I have a WCF service and I want to expose it as both a RESTfull service and as a SOAP service.
Anyone has done something like this before?
Source: (StackOverflow)
I'm a beginner in WCF, but trying to improve my experience. And on the first step I faced the problem. I created the simplest WCF service. The listing of code: (all the code in one file)
using System;
using System.ServiceModel;
namespace EssentialWCF
{
[ServiceContract]
public interface IStockService
{
[OperationContract]
double GetPrice(string ticker);
}
public class StockService : IStockService
{
public double GetPrice(string ticker)
{
return 94.85;
}
}
class Service
{
static void Main(string[] args)
{
ServiceHost serviceHost = new ServiceHost(typeof(StockService),
new Uri("http://localhost:8000/HelloWCF"));
serviceHost.AddServiceEndpoint(typeof(IStockService), new BasicHttpBinding());
serviceHost.Open();
Console.WriteLine("To continue press ENTER");
serviceHost.Close();
}
}
}
That would be the service that give me a number via console. But debug give me the exception: (instead of number :) )
HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).
Have you ever faced the same situation? I will be glad to see every advice.
Thanks in advance.
Source: (StackOverflow)
Update:
I have been trying to turn on WCF tracing, but still no success... Below is my lastest update.
Do I need a permission to write to the below location?
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "@\\myservername\folder1\traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
I am using .NET Framework 3.5.
What is the step-by-step instruction to turn on the WCF tracking for debugging purposes?
Source: (StackOverflow)
I have a WCF service that is hosted in a Windows Service. Clients that using this service must pass an identifier every time they're calling service methods (because that identifier is important for what the called method should do). I thought it is a good idea to somehow put this identifier to the WCF header information.
If it is a good idea, how can I add the identifier automatically to the header information. I mean whenever user called the WCF method the identifier automatically added to the header.
UPDATE:
Clients that are using the WCF service are both Windows applications and Windows Mobile application (Using Compact Framework).
Source: (StackOverflow)
I am developing a WCF web service and I used the WCF Service Application template to do that.
Does creating a "WCF Service Application" fulfill this requirement?
What are the advantage of creating a WCF Service Library over a WCF Service Application?
Source: (StackOverflow)
What is the difference between web reference and service reference in WCF?
Which is preferable in WCF?
Source: (StackOverflow)