February 2005 - Posts

Webservice soap message length limitation

Is there any length limitation of soap message? I mean I could sent entire DataSets over network and It could be a lot of data . And what happens if network disconnection occurs during transmition?  

How to parse HTML?

Does anybody know what is the best way to parse HTML files?

Webservice serialization

I've create class A that includes collection of another class B. I'm trying to use class A with webservice. I've created function that returns class A. When I try to invoke the function in browser it gives me status 500. When I try to use that service with my application it also fails with  “Server was unable to process request. --> There was an error generating the XML document. --> The type MyClass.StudentInfo was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.”  error. Soap serialization through System.Runtime.Serialization.Formatters.Soap worked just fine. I thought these are the same serialization proccess, if not how do I prepare my classes for webservice usage?

Weird VS2003 behavior

A friend of my asked to show him how to start with ASP.NET. He has VS.2003 installed on his PC. So I choosed project name “test” for example ASP.NET application. On project creation VS.2003 just stuck and became not responding. I tried again but this time with “test1” name for the project - the same thing. When we went to my PC (I was sure It will work on my PC because I did it a hundred times), on my PC it also stuck. When I lived the default project name it worked perfectly. Weird...

Problem with IIS intallation after framework installed

When you install IIS after you installed .NET framework you will not be able to run asp.net projects. In this case you need to run aspnet_regiis -i from command line. It locates at %WINDIR%/Microsoft.NET\Framework\v1.1.4322\

Validating URL

Here is an example of function that validates url.

public bool function ValidateUrl(string url)
{
   Uri newUri = new Uri(“Http://“+url);
   try
   {
     WebRequest httpReq = WebRequest.Create(newUri);
     WebResponse httpRes = httpReq.GetResponse();
     HttpWebResponse myRes = (HttpWebResponse)httpRes;

      if(myRes.StatusCode==“OK“)
     {
         return true;
     }
     else
        return false;
   }
   catch (WebException ex)
   {
       return false;
    }

}

Getting output from stored procedure with SqlCommand

I know for many people it is not new but I post It anyway. Creating a stored procedure 
CREATE PROCEDURE AddUser
(
      @UserName nvarchar(100),
      @NewUserId int OUTPUT
) AS
INSERT tUsers (UserName) VALUES(@UserName)
SELECT @NewUserId=@@Identity
RETURN
GO 

Creating a function:
public int AddUser(string userName)
{
      int newId;
      SqlConnection conn = new SqlConnection(connectionSting);
      SqlCommand cmd = new SqlCommand(“AddUser“,conn);
      
cmd.CommandType = CommandType.StoredProcedure;
       
cmd.Parameters.Add("@UserName",userName);
        cmd.Parameters.Add("@NewUserId",SqlDbType.Int);
        cmd.Parameters["@NewUserId"].Direction = ParameterDirection.Output;
        conn.Open();
        cmd.ExecuteNonQuery();
       
newId =
(int)cmdl.Parameters["@NewUserId"].Value;
        conn.Close();
        return newId;
      

}

The evolution of programmer

Nice joke. Unfortunate there is no .Net evolution step :) 

Data access application block performance

I have replaced Data Access Layer of my working project with Enterprise library Data access application block.. not exactly replaces rather implemented :) just to couple small functions.  The first thing I could see that my now project  loads slower. It is about few second, It not a problem for a little data, but I'm afraid that it could affect bigger data chunks.  

String resource file

I'm studing Enterprise Library and I just don't get It... What is string resource file and where It came from?