NOTE: This is objective type question, Please click question title for correct answer. |
No, we cannot propagate CLR Exceptions across service boundaries.
If you want to propagate exception details to the clients then it can be done through "FaultContract " attribute. This way a custom exception is being passed to the client.
Thanks and Regards
Akiii |
The service model returns a generic SOAP fault to the client which does not include any exception specific details by default. However, an exception details in SOAP faults can be included using IncludeExceptionDetailsInFaults attribute. If IncludeExceptionDetailsInFaults is enabled, exception details including stack trace are included in the generated SOAP fault. IncludeExceptionDetailsInFaults should be enabled for debugging purposes only. Sending stack trace details is risky.
IncludeExceptionDetailsInFaults can be enabled in the web.config file :-
<behaviors>
<serviceBehaviors>
<behavior name="ServiceGatewayBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Thanks and Regards
Akiii |
Yes, SOAP faults are inter-operable as they are expressed to clients in XML form.
.Net exception classes are not good to be used in SOAP faults. Instead we should define our own DataContract class and then use it in a FaultContract.
public interface ICalculator
{
[OperationContract]
[FaultContract(typeof(MathFault))]
int Divide(int n1, int n2);
}
[DataContract]
public class MathFault
{
[DataMember]
private string operation { get; set; }
[DataMember]
private string problemType { get; set; }
}
public int Divide(int n1, int n2)
{
try
{
return n1 / n2;
}
catch (DivideByZeroException)
{
MathFault objMath = new MathFault();
objMath.operation = "division";
objMath.problemType = "divide by zero";
throw new FaultException<MathFault>(objMath);
}
}
Thanks and Regards
Akiii |
It is a class by which a service client can interact with the service. The client will make an object of the proxy class and by the help of it will call different methods exposed by the service.
Thanks and Regards
Akiii |
NOTE: This is objective type question, Please click question title for correct answer. |
Simplex - Also known as one way communication. Source will send a message to the target, but target will not respond to the message.
Request/Replay - It is two way communications, source send message to the target, target will resend the response message to the source. But in this scenario at a time only one can send a message (that is), either source or destination.
Duplex -Also known as two way communication, both source and target can send and receive message simultaneously.
Thanks and Regards
Akiii |
|
[MessageContract]
public class EmployeeDetails
{
[MessageHeader]
public int ID;
[MessageBodyMember]
public string First_Name;
[MessageBodyMember]
public string Last_Name;
}
Message contract can be applied to type using MessageContract attribute as shown above. We can add custom header and custom body by using MessageHeader and MessageBodyMember attribute respectively.
When EmployeeDetails type in the service operation is used as parameter then WCF will add an extra header call 'ID' to the SOAP envelope. It also add First_Name, Last_Name as an extra member to the SOAP Body.
Thanks and Regards
Akiii |
When we need a higher level of control over the message, such as sending custom SOAP header, then we can use MessageContract instead of DataContract . But in general cases, most of the messaging needs can be fulfilled by DataContracts.
Thanks and Regards
Akiii |
(1) Inter-operability with applications built on differnet technologies.
(2) Unification of the original Dotnet Framework communication Technologies.
(3) Support for Service Oriented Architecture (SOA).
Thanks and Regards
Akiii |
Web Service (that is), ASMX will be the most likely way to achieve cross-vender inter-operability.
Thanks and Regards
Akiii |
NOTE: This is objective type question, Please click question title for correct answer. |
The three components that a WCF must implement are :-
(1) Service Class = This can be implementated in any dotnet language. It implements one or more methods.
(2) Host Process = A process in which the service will run.
(3) End-Points = One or more end-points are provided that allow the clients to access the service.
Thanks and Regards
Akiii |
NOTE: This is objective type question, Please click question title for correct answer. |
If you do not specify " [OperationContract] " in any of the methods in your interface then you will get the following error :-
IService1' has zero operations; a contract must have at least one operation
Here, Iservice is the name of my Interface. you can have your own name.
So, it is mandatory to label " [OperationContract] " attribute to at least one method while declaring your interface methods or ServiceContract.
Thanks and Regards
Akiii |