Welcome to MSDN Blogs Sign in | Join | Help

Introduction to Biztalk

BizTalk is an Enterprise Application Integration (EAI) tool. It can be used to integrate applications running within an organization or outside the organization. Typical example for the first scenario would be integrating a SAP application with a purchase order application. A B2B application is a good example for the second scenario where applications from different organizations are integrated.

BizTalk works based on the content-based publish/subscribe architecture. Within BizTalk, the communication is using xml.

How it works at a high level

BizTalk receives the data using the receive port/adapter and uses one of protocols - file, http, soap etc to communicate with the external application. Once the data is received by the adapter, it passes through the receive pipeline (series of components), gets converted into xml messages and is stored in the SQL Server database. If there any business processes or business rules that needs to be performed, it is done in orchestration as shown below. Once the orchestration is done, the message is written back to the database; from here it is picked up by the send pipeline/adapters depending on the subscriptions. The send adapter converts the xml message into a format which is understood by the target application.

Will post more articles as I progress with Biztalk.

Posted by karthics | 1 Comments

Learning Biztalk

I'm getting my hands dirty with Biztalk.  Very soon you will see some articles on Biztalk here :-)

Posted by karthics | 0 Comments

How to enable http compression for a folder in IIS 6.0

By default, when you try to enable compression for a folder in IIS 6.0, you will get the following error message

G:\Inetpub\AdminScripts>cscript adsutil.vbs set w3svc/1/root/sample/DoDynamicCompression true
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

The path requested could not be found.
ErrNumber: -2147024893 (0x80070003)
Error Trying To Get the Object: w3svc/1/root/sample

In order to make it work, you will have to create a key for the folder in the IIS metabase

To create a key, go to the properties of the folder and enable and disable the log visits check box or if its already enabled, disable and enable it again and click on apply and ok. This will create the following key in the metabase.

<IIsWebDirectory Location ="/LM/W3SVC/1/ROOT/sample">
<Custom Name="UNCPassword" ID="3003" Value="49634462500000000600000040000000b948cacfe79500009c1b6d08e34531889ceb6984a2feb9d7d3c8ade09b7ff295b59459ff6d47380aca6382e06e7957c3335a4dd5604625dec0b5d7a350161fa8c9b55089ae494e7a"
Type="STRING"
UserType="IIS_MD_UT_FILE"
Attributes="INHERIT | SECURE"
/>

Once the above key is created for the folder in the metabase, you should be able to enable compression at the folder level by running the following commands from the inetpub\adminscripts folder

1) cscript adsutil.vbs set w3svc/<WebSiteIdentifier>/Root/<FolderName>/DoDynamicCompression true for enabling dynamic compression
2) cscript adsutil.vbs set w3svc/<WebSiteIdentifier>/Root/<FolderName>/DoStaticCompression true for enabling static compression

Posted by karthics | 1 Comments

How a session id is generated for an aspx page in .net framework 1.1

In this blog, I just wanted to write about the method within the .net framework which is responsible for generating the session id when a client requests an aspx page for the first time. This article doesn’t talk about the various scenarios under which the session id is created.

I was curious to know which class/method within the .net framework is used to generate the session id when a request for an aspx page comes in. I was looking at the SessionStateModule class under the System.Web.SessionState namespace using the .net reflector written by Lutz Roeder - http://www.aisto.com/roeder/dotnet/

Inside this class, there is a method with the following signature

private IAsyncResult BeginAcquireState(object source, EventArgs e, AsyncCallback cb, object extraData)
{

}

Within this method, there is an if else statement which checks if the private string rqId is null or not. This is the string which actually stores the session id.

if (this._rqId != null)

{

      sessionStateItem = this.GetSessionStateItem();

}

else

{

      this._rqId = SessionId.Create(ref this._randgen);

      if (!s_config._isCookieless)

      {

            HttpCookie cookie = CreateSessionCookie(this._rqId);

            if (!this._rqContext.Response.IsBuffered())

            {

                throw new HttpException(HttpRuntime.FormatResourceString("Cant_write_session_id_in_cookie_because_response_was_flushed"));

            }

            this._rqContext.Response.Cookies.Add(cookie);

            this._rqAddedCookie = true;

      }

      else

      {

            this._rqContext.Response.SetAppPathModifier(AppPathModifierFromSessionId(this._rqId));

            HttpRequest request = this._rqContext.Request;

            string url = request.Path;

            string queryStringText = request.QueryStringText;

            if ((queryStringText != null) && (queryStringText.Length > 0))

            {

                url = url + "?" + queryStringText;

            }

            this._rqContext.Response.Redirect(url, false);

            this._rqAr.Complete(true, null, null);

            IAsyncResult result = this._rqAr;

            application.CompleteRequest();

            return result;

      }

}

In the above code snippet, if the rqId string is null, then the Session.Create method is called.

Session is an internal class within the System.Web.SessionState namespace which has a static method Create with the following definition

internal static string Create(ref RandomNumberGenerator randgen)

{

    if (randgen == null)

    {

        randgen = new RNGCryptoServiceProvider();

    }

    byte[] data = new byte[15];

    randgen.GetBytes(data);

    return Encode(data);

}

Once the session id is generated, depending on how the cookieless attribute is set in the web.config (set to true or false) file; the session id is either added to the cookies collection or added to the URL. 

Scenario 1 : Cookieless attribute set to false

If the cookieless attribute is set to false, then the session id is added to the cookies collection by making a call to the CreateSessionCookie method

private static HttpCookie CreateSessionCookie(string id)

{

    HttpCookie cookie = new HttpCookie("ASP.NET_SessionId", id);

    cookie.Path = "/";

    return cookie;

}

After the cookie is created, it is added to the Response.Cookies collection.  I was able to check the request and response headers using the fiddler tool (www.fiddlertool.com). 

HTTP Request Header :

GET /webapplication1/webform1.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727)
Host: win2k3-6114
Proxy-Connection: Keep-Alive

HTTP Response Header :

HTTP/1.1 200 OK
Date: Tue, 29 May 2007 07:44:27 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=iddajxme35irfr45tcynode1; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 662

Notice the name of the cookie in the response header.  You will also see this in the IIS log, once you enable the Cookie field for the specific web site and access the aspx page.  

IIS Log:

#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Cookie) sc-status sc-substatus sc-win32-status

2007-05-28 05:04:03 W3SVC1 65.52.76.126 GET /webapplication1/webform1.aspx - 80 - 65.52.76.126 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322;+InfoPath.2;+.NET+CLR+2.0.50727) ASP.NET_SessionId= iddajxme35irfr45tcynode1 200 0 0

Scenario 2 - Cookieless attribute set to true

If the cookieless attribute is set to true, then the session id is added to the url.  In this case, two trips are made to the server.  First time, when the page is requested, the server responds with status code 302 (object moved) and in the next request, the server responds with status code 200 (OK. The client request has succeeded).  This is because once the session id is added to the url, the Response.Redirect method is called. Notice the request and the response headers below. 

HTTP Request Header : 

GET /webapplication1/webform1.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727)
Host: win2k3-6114
Proxy-Connection: Keep-Alive

HTTP Response Header :

HTTP/1.1 302 Found
Date: Tue, 29 May 2007 08:06:19 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Location: /webapplication1/(n2xrh3452rylcuevsv103cep)/webform1.aspx
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 662

HTTP Request Header : 

GET /webapplication1/(n2xrh3452rylcuevsv103cep)/webform1.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727)
Host: win2k3-6114
Proxy-Connection: Keep-Alive

HTTP Response Header :

HTTP/1.1 200 OK
Date: Tue, 29 May 2007 08:06:19 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 662

You will not see the cookie being set in the response headers. 

If you check the URL, it will look something like this

http://<ServerName>/webapplication1/(n2xrh3452rylcuevsv103cep)/webform1.aspx 

In the IIS log, you will see two entries for webform1.aspx page, one with status code 302 and the next one with status code 200. However, the cookie value will be empty.  

IIS Log: 

#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Cookie) sc-status sc-substatus sc-win32-status

2007-05-29 08:06:19 W3SVC1 65.52.76.126 GET /webapplication1/webform1.aspx - 80 - 65.52.76.126 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322;+InfoPath.2;+.NET+CLR+2.0.50727) - 302 0 0

2007-05-29 08:06:19 W3SVC1 65.52.76.126 GET /webapplication1/webform1.aspx - 80 - 65.52.76.126 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322;+InfoPath.2;+.NET+CLR+2.0.50727) - 200 0 0 

I hope you enjoyed reading this article.

Posted by karthics | 1 Comments
 
Page view tracker