Sunday 7 June 2015

How to Spilt string sql server ?

In this post I wrote a SQL function to split string in sql server. In most of cases we need to split sql string.


Creating sql function:-

CREATE FUNCTION [dbo].[fnSplitSqlString]
(
    @string nvarchar(MAX),
    @delimiter char(1)
)

 RETURNS @output table
  (
   SplitData nvarchar(MAX)
  )

BEGIN
    DECLARE @start int, @end int
    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)
    WHILE @start < LEN(@string) + 1 BEGIN
        IF @end =
            SET @end = LEN(@string) + 1
      
        INSERT INTO @output (splitdata) 
        VALUES(SUBSTRING(@string, @start, @end - @start))
        SET @start = @end + 1
        SET @end = CHARINDEX(@delimiter, @string, @start)
       
    END
    RETURN
END

Calling above function :-


Select * from [dbo].fnSplitSqlString('SQL$ASP.NET$WCF$JQuery$c#.NET','$')

Output:-



















I hope you enjoyed this post. Please comments your feedback and questions.

Thursday 4 June 2015

What are the WCF specifications ?

In this post I explained what are the specifications does WCF  follow. You can learn more about WCF in my other post by clicking on WCF menu tab.

Web Service standards and specifications are known as "WS-*". These represents a set of protocols and specifications. These are used to extend the capability of web service.

The Web Services Interoperability Organization (WS-I) is an industry group to promote interoperability across the stack of web services specifications. It publishes web service profiles, sample applications, and test tools for help. One of the popular profiles it has published is the WS-I Basic Profile. WS-I is governed by a Board of Directors, and Microsoft is one of the board members.

WCF supports specifications defined by WS-* specifications. WS-* specifications are defined together by Microsoft, IBM, SUN, and many other big companies so that they can expose there services through a common protocol. WCF supports all specifications defined and now we will learn them one by one.

1. Messaging (WS-Addressing): -

SOAP is the fundamental protocol for web services. WS Addressing defines some extra additions to SOAP headers, which makes SOAP free from the underlying transport protocol. One of the good things about message transmission is MTOM, also termed as Message Transmission Optimization Mechanism. They optimize the transmission format for SOAP messages in XML-Binary format using XML optimized packaging (XOP). Because data will sent in binary and optimized format, it will give us a huge performance gain.

2. Security (WS-Security, WS-Trust, and WS-Secure Conversation):-

 All the three

  1. WS-Security, 
  2. WS-Trust, and
  3. WS-Secure Conversation

WS- define authentication, security, data integrity, and privacy features for a service.

3. Reliability (WS-Reliable Messaging): -

Reliability specification ensures end-to-end communication when we want SOAP messages to be transmitted over the network back and forth many times.

4. Transactions (WS-Coordination and WS-Atomic Transaction):

 These two specifications WS-Coordination and WS-Atomic Transaction enable transaction with SOAP messages.

5. Metadata (WS-Policy and WS-Metadata Exchange): -

WSDL is an implementation of the WS-Metadata Exchange protocol. WS-Policy defines more dynamic features of a service, which cannot be expressed by WSDL. We have stressed on the WS-* specification as it is a specification which a service has to follow to be compatible with other languages. Because WCF follows WS-* specifications, other languages like Java, C++ can also exploit features like Messaging, Security, Reliability, and transactions written in C# or VB.NET. This is the biggest achievement of WCF to integrate the above features with other languages.



These are the specificationd followed by WCF. I hope its very useful and you enjoyed this post. Please comments your feedback and questions.