The book of inspiration

December 29, 2009

OrcasMetaWebService

Filed under: jsc — Tags: , , , , — zproxy @ 2:11 pm

Let’s build some muscle on jsc.

OrcasMetaWebService. Crosscompiled from C# to Java for Google App Engine and PHP.

The idea is that your little cute Web Service will be running on PHP and Google App Engine. See the C# source code used in this example over here.

  • See live example running on PHP.
  • See live example running on Google App Engine java

There are features missing. But you sure can see where it is going 🙂

PS. Video parameters “&w=800&h=500&fmt=18″

Update:

I had this idea to publish the web services via WSDL with HTTP Protocol. But it seems this scenario isn’t exactly supported by the big old Microsoft just yet. So the next step would be to implement xml-soap?

See also:

May 15, 2009

URLRequestHeader

Filed under: jsc — Tags: , , — zproxy @ 8:35 am

The other day a developer named Carlo emailed me noted that currently URLRequestHeader is not exposed via ScriptCoreLib. In response to that I exposed those classes and created an example solution to demonstrate it. You would need to redownload jsc to get it ofcourse.

Before going into that I would like to show how one could add a native type that is not yet defined by other assemblies like ScriptCoreLib. In your assembly you would need to define a new type like this:

6 namespace ScriptCoreLib.ActionScript.flash.net

7 {

8 // http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequestHeader.html

9 [Script(IsNative = true)]

10 public class URLRequestHeader

11 {

The compiler will later then assume that this type is provided by the platform itself or imported by some other means and use it as a native type.

The actionscript livedocs had a nice example which I translated to C#.

44 var loader = new URLLoader();

45

46 var header = new URLRequestHeader(“XMyHeader”, “got milk?”);

47

48 t.appendText(“\n” + this.loaderInfo.url);

49 t.appendText(“\nUsing relative path…”);

50

51 var request = new URLRequest(“../WebForm1.aspx”);

52 var data = new DynamicContainer { Subject = new URLVariables(“name=John+Doe”) };

53 data[“age”] = 23;

54

55 request.data = data.Subject;

56 request.method = URLRequestMethod.POST;

57 request.requestHeaders.push(header);

58

59 loader.complete +=

60 args =>

61 {

62 t.appendText(“\n” + loader.data);

63 };

64

65 loader.load(request);

In this demo I am sending three elements of data to the server:

  1. header XMyHeader
  2. post parameter name
  3. post parameter age

As we need a server to echo something back for us to see it works I added a new ASP.NET Web Application to the solution. The flash file generated by the jsc compiler will be copied to a folder Generated. The generated files are not included in the svn. This is why the solution will show exclamation marks on the first build.

headerserver

The WebForm1 implements the echo service like this:

10 public partial class WebForm1 : System.Web.UI.Page

11 {

12 protected void Page_Load(object sender, EventArgs e)

13 {

14 var data = new

15 {

16 XMyHeader = this.Request.Headers[“XMyHeader”],

17 name = this.Request.Params[“name”],

18 age = this.Request.Params[“age”],

19

20 };

21

22 this.Response.Write(“hi! “ + data.ToString());

23 this.Response.End();

24 this.Response.Close();

25 }

26 }

Running  it in the browser will give us the following view including the current URL and the text returned by the server.

headerhtml

The source code for this example is available here:

http://jsc.svn.sourceforge.net/viewvc/jsc/examples/actionscript/URLRequestHeaderExample/

As this is a dirty fast example – If anything needs clarification do let me know.

August 5, 2008

Extend your ASP.NET with C# to JavaScript tutorial

Filed under: jsc — Tags: , , , — zproxy @ 9:37 am

I have added a new tutorial for those of you who would like to extend existing ASP.NET web sites with jsc compiler.

Read the tutorial over here.

Update: This tutorial is now a part of the google jsc site.

June 12, 2008

Jsc June Refresh 2

Filed under: jsc — Tags: , , , , , , , , , , — zproxy @ 4:29 pm

Some updates to the compiler and the framework: Download jsc here. (Others already have!)

Added two Java project templates.

Visit our google groups.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# to JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site
OrcasJavaConsoleApplication – C# to Java as Console Application
OrcasNativeJavaConsoleApplication – C# to Java as Console Application with JNI bindings.

Have a look at some old screencasts:

June 6, 2008

Jsc June Refresh

Filed under: jsc — Tags: , , , , , , , , , , — zproxy @ 2:43 pm

Some updates to the compiler and the framework: Download jsc here.

Most important update was fixing the virtual + override semantics for jsc:actionscript. It’ did not allow to combine multiple events for example.

Visit our google groups.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# To JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site

Writing code in VB.NET for flash looks like this:

June 4, 2008

ASP.NET Web Site Template

Filed under: jsc — Tags: , — zproxy @ 2:24 pm

The new download – ASP.NET Web Site Template is available here. It includes the jsc compiler thus no need to install it. Download the zip and extract it under your ‘My Documents\Visual Studio 2008\Templates\ProjectTemplates‘. Create a new Web Site and view the ‘Default.aspx‘ in the browser. It should also work with the Visual Web Developer Express.

Create new project

Explore your solution

View in browser

See the generated HTML

It just works doesn’t it 🙂

Blog at WordPress.com.