using

System;

 

namespace

Galileo.Web.Services

{

///

<remarks/>

[System.ComponentModel.DesignerCategoryAttribute("code")]

public

class EnhancedSoapHttpClientProtocol : System.Web.Services.Protocols.SoapHttpClientProtocol

{

public

bool Expect100Continue { get { return _expect100Continue; } set { _expect100Continue

= value; } }

 

private

bool _expect100Continue;

 

///

<remarks/>

public

EnhancedSoapHttpClientProtocol()

}

 

protected

override WebRequest GetWebRequest(Uri uri)

{

//

The following disables 100-continue for web service requests,

 

//

Declare locals.

System.Net.WebRequest

request = null;

 

//

Grab the instance of the request that will be used to service this call

if(_gZipRequest)

gZipRequest.Headers["Content-Encoding"]

= "gzip";

//

keepAlive is valid only for HTTP 1.1 and above

gZipRequest.ProtocolVersion

= _protocolVersion;

request

= gZipRequest;

}

else

//

keepAlive is valid only for HTTP 1.1 and above

httpRequest.ProtocolVersion

= _protocolVersion;

request

= httpRequest;

}

 

//

The SoapHttpClientProtocol does not respect the Preauthenticate property.

{

System.Net.NetworkCredential

nc = this.Credentials.GetCredential(uri,"Basic");

{

string

credentials = string.Format("{0}:{1}", nc.UserName, nc.Password);

string

encodedCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));

request.Headers["Authorization"]

= string.Format("Basic {0}", encodedCredentials);

}

}

 

if(_acceptGZip)

 

//

The HttpWebRequest.KeepAlive property controls whether or not

 

//

Return the request object.

return

request;

}

 

protected

override WebResponse GetWebResponse(WebRequest request)

//Putting

validation to check the header beforhand so that if user requested for

gzip response but response header doesnt have // content-encoding element then we dont need to process response based

on the code block under _acceptGZip

HttpWebResponse

httpresponse = (HttpWebResponse) request.GetResponse();

 

if(httpresponse.ContentEncoding

!= "gzip" && _acceptGZip != false)         _acceptGZip

= false;

{

if(_acceptGZip)

else

 

protected

override WebResponse GetWebResponse(WebRequest request, IAsyncResult ar)

//Putting

validation to check the header beforhand so that if user requested for

gzip response but response header doesnt have // content-encoding element then we dont need to process response based

on the code block under _acceptGZip

HttpWebResponse

httpresponse = (HttpWebResponse) request.GetResponse();

 

if(httpresponse.ContentEncoding

!= "gzip" && _acceptGZip != false)        _acceptGZip

= false;

{

 

if(_acceptGZip)

}

}

}

}

}