Powered By Blogger

Monday, September 11, 2023

WCF Notes(Contract)

Contract

Collection of operation that specifies what the endpoint will communicate with outside world. Usually name of the Interface will be mentioned in the Contract, so the client application will be aware of the operations which are exposed to the client. Each operation is a simple exchange pattern such as one-way, duplex and request/reply.

Below figure illustrate the functions of Endpoint

Example for End Points

Endpoints will be mentioned in the web.config file on the created service.
<system.serviceModel>
<services>
      <service name="MathService"
        behaviorConfiguration="MathServiceBehavior">
       <endpoint
         address="http://localhost:8090/MyService/MathService.svc" contract="IMathService"
          binding="wsHttpBinding"/> 
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MathServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

Difference between WCF and Web service

Difference between WCF and Web service

Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.

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

Thursday, June 19, 2014

some useful queries in SQL

Query to list all employees except who are joined on 11- Sep-2001, 31-Mar-2001 and 30-Jan-2001(It also compares time).

   SELECT * FROM EMP WHERE HIREDATE NOT IN ( DATE('09-11-2001'),
                                          DATE('03-31-2001'),DATE('01-30-2001') )

 To list all the employees whose names are having ‘O’ as second character
       SELECT * FROM EMP WHERE ENAME LIKE '_O%'

 To list all the employees whose names are having ‘R’ as last character
       SELECT * FROM EMP WHERE ENAME LIKE '%R'

 To list all the employees whose names are having just 5 characters as length.
      SELECT * FROM EMP WHERE LENGTH(ENAME) = 5      

 To list all the employees whose names are starting with  ‘R’ and ending with ‘O’
   SELECT * FROM EMP WHERE ENAME LIKE 'R%O'

Tuesday, June 10, 2014

Some Useful Queries in Sql

-- Write a query to list the employees whose salaries are within the range of 5000 and 10000
   SELECT * FROM EMP WHERE SAL BETWEEN 5000 AND 10000

-- Write a query to list the employees who have joined in the month of March’99
   SELECT * FROM EMP WHERE MONTHNAME(HIREDATE)='March' AND YEAR(HIREDATE)=1999

-- Write a query to list the employees whose salaries are not within the range of 10000 and 13000
   SELECT * FROM EMP WHERE SAL NOT BETWEEN 10000 AND 13000

-- Write a query who are getting 1000, 2000, 3000
   SELECT * FROM EMP WHERE SAL IN (1000,2000,3000)

-- Query to list all employees except who are joined on 11- Sep-2001, 31-Mar-2001 and 30-Jan-2001(It also compares time).
   SELECT * FROM EMP WHERE HIREDATE NOT IN ( DATE('09-11-2001'),
                                          DATE('03-31-2001'),DATE('01-30-2001') )

Development Tools of WCF

Development Tools

WCF application can be developed by the Microsoft Visual Studio. Visual studio is available at different edition. You can use Visual Studio 2008 Expression edition for the development.
Visual Studio 2008 SDK 1.1

Microsoft Visual Studio 2008


Microsoft Visual studio 2008 provides new features for WCF compared to Visual Studio 2005. These are the new features added to VS 2008.

Different Technology Combined to form WCF.

Below figures shows the different technology combined to form WCF.