Friday, 19 April 2013

WCF and Web Services - Sandeep Kanao

Webservice : How to access session variables - Sandeep KanaoDefine an attribute that indicates you require a session
[WebMethod(EnableSession = true)]
public void MyWebService()
{
    Foo foo;
    Session["MyObjectName"] = new Foo();
    foo = Session["MyObjectName"] as Foo;
}

WCF : How to access session variables  - Sandeep KanaoSet aspNetCompatibilityEnabled = true inside system.ServiceModel | serviceHostingEnvironment
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
On client
<basicHttpBinding>
 <binding name="SessionBinding" allowCookies="true">
</basicHttpBinding>
Solution 2 :
Use OperationContext

WCF : How to access web service in WCF service - Sandeep KanaoLike asp.net - by creating webservice proxy class or by adding reference

 Major difference between WCF and Webservice - Sandeep Kanao is that Web Services use XmlSerializer but WCF uses DataContractSerializer which is better in performance as compared to XmlSerializer. Some key issues with XmlSerializer to serialize .NET types to XML are:
* Only Public fields or Properties of .NET types can be translated into XML.
* Only the classes which implement IEnumerable interface.
* Classes that implement the IDictionary interface, such as Hash table can not be serialized.
Important difference between DataContractSerializer and XMLSerializer:
* A practical benefit of the design of the DataContractSerializer is better performance over Xmlserializer.
* XML Serialization does not indicate the which fields or properties of the type are serialized into XML where as DataCotratSerializer Explicitly shows the which fields or properties are serialized into XML.
* The DataContractSerializer can translate the HashTable into XML


Tuesday, 2 April 2013

Market Risk vs Credit Risk - Sandeep Kanao

Market RiskPotential loss in market value of our position if a market risk factor goes against our position.  VaR is the common measure used

Credit Risk
Credit Risk = Exposure x Credit Worthiness x Severity

Exposure
Potential loss as a result of counterparty default

Credit Worthiness
Probability of default or credit migration

Severity
Fraction loss give default
Severity = 1 – Recovery Rate

Methods for Measuring Counterparty Exposure - Sandeep Kanao

Portfolio Simulation MethodSimulate multiple scenarios of future values of risk factors. E.g. FX rates, Interest Rates, Commodity and Equity prices…
Value each deal in the portfolio using simulated market risk factors as input to pricing models
Aggregate counterparty exposure using appropriate netting rules, margin and collaterals agreements
Calculate the exposure measures
Confidence level exposure (e.g. 95%)
Expected Exposure and Effective Exposure