Mar 20, 2008

Proxy class generation from WSDL in .NET 2.0 and .NET3.0

Proxy class generation from WSDL in .NET 2.0

The following command creates a .wsdl file for the XML Web service located at the specified URL and creates a client proxy class in the C# language for the XML Web service.

wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

The following command creates a client proxy class in the C# language for an XML Web service located at the specified URL. The tool saves the client proxy class in the file myProxyClass.cs

wsdl /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

For more visit to:

http://msdn2.microsoft.com/en-us/library/7h3ystb6(VS.71).aspx

Proxy class generation from WSDL in .NET 3.0

Use this command to generate proxy class from a web service.

WseWsdl3 http://hostServer/WebServiceRoot/WebServiceName.asmx?WSDL /out:MyProxyClass.cs

This will generate the class MyProxyClass.cs which we can include in our solution to create an object of this and then call the appropriate method.

For more visit to :

http://msdn2.microsoft.com/en-us/library/aa529578.aspx

Mar 4, 2008

Passing Data from one sp to other sp using Temp Table.

Passing Data from one sp to other sp using Temp Table.

 

Hi,

Here I tried a trick, there may be others trick also to do the same.

 

 

CREATE PROCEDURE Proc_Record_Insertion

AS

-- This #Temp1 table is defined in the other sp which I am using here.

INSERT INTO #Temp1(id,info) VALUES(1,'Mohammad')

INSERT INTO #Temp1(id,info) VALUES(2,'Irfan');

INSERT INTO #Temp1(id,info) VALUES(3,'matespoint@gmail.com');

INSERT INTO #Temp1(id,info) VALUES(4,'matespoint.blogspot.com');

GO

-- This will create a sp Proc_TempTableCreate which create a Temp table and insert four recors into it.

 

CREATE PROCEDURE Proc_UseTempData

AS

BEGIN

CREATE TABLE #Temp1

            (id int,

             info varchar(40) )

 

-- Executing the sp

EXEC Proc_Record_Insertion

 

SELECT * FROM #Temp1

END

Reading URL thru HttpRequest in C#

Here is the sample code for reading Http request.

 

HttpWebRequest request = null;

   string url = “http://matespoint.blogspot.com”

   // Create web request

   request = (HttpWebRequest)WebRequest.Create(url);

   // Set value for request headers

   request.Method = "GET";

   request.ProtocolVersion = HttpVersion.Version11;

   request.AllowAutoRedirect = false;

   request.Accept = "*/*";

   request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";

   request.Headers.Add("Accept-Language", "en-us");

   request.KeepAlive = true;

 

   StreamReader responseStream = null;

   HttpWebResponse webResponse = null;

   string webResponseStream = string.Empty;

   // Get response for http web request

   webResponse = (HttpWebResponse)request.GetResponse();

   responseStream = new StreamReader(webResponse.GetResponseStream());

 

// Read web response into string

   webResponseStream = responseStream.ReadToEnd();

 

Mar 3, 2008

IF EXIST Vs COUNT(*) - SQL Server

IF EXIST Vs COUNT(*)

 

Many times we see that people use count(*) to get the condition that if we have any record like

IF (SELECT COUNT(*) FROM Employee where Salaried =0 ) >0

BEGIN

PRINT 'Yes Got It'

-- Do your calculation here.

END

 

We are doing some calculation if we get Salaried=0 for at least once. And I know many times we use the same trick.

"The cost for getting the count(*) is that it counts all the data we get by where clause."

Use if exist to reduce this overhead.

IF EXISTS(SELECT * FROM Employee where Salaried =0)

BEGIN

PRINT 'Yes Get it'

-- Do your calculation here.

END

 

In this as soon as we get the first record further execution stops and it comes out of the if condition with true. If this not get any result then will cost same as above query.

 

SQL - Difference between CAST,CONVERT and PARSE

TODO---