Saturday, April 22, 2006

Approach One: source code is compiled "on-the-fly" on the server

Approach One:source code IS compiled "on-the-fly" on the server

Pros: easy to test from front-end app

Cons: source code can be inspected from the server, sensitive code might be seen. might be slower than compiled(dll)

*** Create webservices on server. 1 step ***

Create nerd.asmx file on server on c:\inetpub\wwwroot ...


<% @ WebService Language="C#" class="Mate" %>

using System;

using System.Web.Services;

using System.Web.Services.Protocols;

[WebService(Namespace="http://yourserveraddresshere/")]
public class Mate : WebService

{


[WebMethod]
public string TheServerTime()
{
return " of the jedi " + DateTime.Now.ToString();
}

}



...create nerd.asmx file

to test if your services is working, from your development machine open in your favorite browser this site: http://yourserveraddresshere/nerd.asmx


*** To consume webservices in your development machine. 3 steps...

step 1 of 3.

create a code that parses your webservices to get the result, this can be automated using the code generator, use wsdl of .NET SDK...

wsdl.exe http://yourserveraddresshere/nerd.asmx

Note: this will generate Mate.cs file on your development machine

...create a code that parses

step 2 of 3.

create usenerd.cs file on your development machine ...



public class A
{
public static void Main()
{
Mate m = new Mate();
System.Console.WriteLine(m.TheServerTime());
}
}


... create usenerd.cs file

step 3 of 3.

compile and run the application...

csc.exe usenerd.cs Mate.cs

usenerd.exe

...compile

*** To consume webservices in your development machine. using VB.NET. 3 steps...

step 1 of 3.

create a code that parses your webservices to get the result, this can be automated using the code generator, use wsdl of .NET SDK...

wsdl.exe /l:vb http://yourserveraddresshere/nerd.asmx

Note: this will generate Mate.vb file on your development machine

...create a code that parses

step 2 of 3.

create usenerd.vb file on your development machine ...



Public Class A

Public Shared Sub Main()

Dim m As Mate = new Mate()
System.Console.WriteLine(m.TheServerTime())
End Sub
End Class


... create usenerd.cs file

step 3 of 3.

compile and run the application...

vbc.exe usenerd.vb Mate.vb

usenerd.exe

...compile

No comments: