REST is an acronym standing for Representational State Transfer and described as a architecture style based on client-server pattern.
This style is an effective and simple approach to create, retrieve, update and delete information with java script in web browsers.
// Consumer code
service = new XMLHttpRequest();
service.open("GET", "/services/getname.aspx?ID=12333", false);
service.send("");
name = service.responseText;
// Provider code
if(Request.Method == "GET")
{
Response.Clear();
Response.ContextType = "text/plan";
string name = FindUserName(Request.QueryString["id"]);
Response.Write(name);
}
Web Services with SOAP works much better for complex data types and strong-typed programming languages like C#, Java and C++.
Thursday, December 6, 2007
Wednesday, December 5, 2007
Daemon process with Mono
Use API daemon() for BSD Unix computers to create background jobs.
using System;
using System.Runtime.InteropServices;
class DaemonApplication
{
[DllImport ("__Internal", EntryPoint="daemon")]
static extern int daemon (int nochdir, int noclose);
public static void Main(string[] args)
{
System.Console.WriteLine("Starting daemon..." );
daemon(0, 0);
while(true)
{
System.Threading.Thread.Sleep(100);
}
}
}
using System;
using System.Runtime.InteropServices;
class DaemonApplication
{
[DllImport ("__Internal", EntryPoint="daemon")]
static extern int daemon (int nochdir, int noclose);
public static void Main(string[] args)
{
System.Console.WriteLine("Starting daemon..." );
daemon(0, 0);
while(true)
{
System.Threading.Thread.Sleep(100);
}
}
}
Tuesday, December 4, 2007
Using wildcard certificates with Mono
Using Mono with wildcard certificates requires that you override default policy. This is a sample in C# 1.1 to override host name policy by implement interface ICetificatePolicy.
public class Policy : ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint sp, X509Certificate c, WebRequest r, int e)
{
if(e == 0 || e == -2146762481) // CertCN_NO_MATCH
return true;
else
return false;
}
}
class TestApplication
{
public static void Main(string[] args)
{
System.Net.ServicePointManager.CertificatePolicy = new Policy();
TestWS service = new TestWS();
service.Url = "https://services.host.se/Test.asmx";
service.DoSomething();
}
}
public class Policy : ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint sp, X509Certificate c, WebRequest r, int e)
{
if(e == 0 || e == -2146762481) // CertCN_NO_MATCH
return true;
else
return false;
}
}
class TestApplication
{
public static void Main(string[] args)
{
System.Net.ServicePointManager.CertificatePolicy = new Policy();
TestWS service = new TestWS();
service.Url = "https://services.host.se/Test.asmx";
service.DoSomething();
}
}
Sunday, December 2, 2007
My Linux server
This Linux server has been running since 2003 to improve and develop my knowledge of Internet protocols and standards.The computer is connected to Internet 24 hour every day with network applications to track security incidents.
Powered by Debian Linux 4.0
Saturday, December 1, 2007
My new computer
I have used my Apple MacBook computer for a week now. It is a perfect computer because I could use both Apple Mac OSX and Microsoft Windows. In my professional work we create applications for Windows environment, so therefore it is exciting to use technologies from other vendors.
Why Nysele
Nysele is a place in north Sweden. I was born there in early 60's and have continually visit this home place in my life when I want to escape from daily chores.
Subscribe to:
Posts (Atom)