JayData Makes Web Phenomenal !


 

Creating Single Page Application, Web API, Upshot, An Exposed Service bring your data from Json Endpoints (maybe WEB API) … all of this is the new nueva moda.

This is nice till now. But the catastrophy started when you want to map your JSON with your EF Objects. Serializing stuff! Not Serializble! What the Hell! so change return type to ‘dynamic’ and bring ‘anonymous object’ … upshot is not documented!! And the Single Page Architecture Template (which is provided by Microsoft) .. Not mature enough! So simply they removed it from VS 12.

And Finally God guide me to JayData! Its amazing and phenomenal.

That’s what happened to me when I saw the first video for JayData

Imagine, Silverlight RIA can be used in Web. This “Framework” .. not just library

Solve this things in Previous Microsoft Single Page Architecture:

  • Generating the whole EF Model + Metadata automatically using JaySvcUtil.exe (You can see this in video)
  • Do not bother your self by creating many Web API controllers and doing all that mapping stuff between C# and JavaScript.
  • Getting optimized Data (Just needed data):

7-31-2012 6-02-35 AM

In this image you can see how I’m getting the Whole users from the WCF Data Service.

map ==> Used to get a specific properties from the object (That’s will minimize the size of the requested data; which means some KBs instead getting the whooole object).

Also I’m using Knockout to bind UI Elements with self.users observable array

7-31-2012 6-08-34 AM

  • You can use LINQ in JavaScript. Haha, Brilliant! For example if you have a users table and People table. And Each User is a Person. Lets see how to get Person Data if you clicked on a User.

7-31-2012 5-52-38 AM

First Param is a predicate that brings a person by Id.

this.Id ==> Passed in Second param as you see.

And Third one; is the callbacks from the operation. Awesome!

showPerson binded with list of users using Knockout JS (2nd image shows how I binded Div Element with showPerson function).

What else, See this video

http://nuget.org/packages/JayData

http://jaydata.org/

http://jaydata.org/api

Host WCF Service in WAS


Before doing these steps; host your WCF service in IIS. I assumed that you already did that. And my target here is to host the service in WAS with net.tcp port 🙂 thank you.

Installing WAS (you can ignore these steps if WAS already installed)

1.Control Panel >> Programs.
2.Under Programs and Features, click Turn Windows Features On And Off.
3.Select Windows Process Activation Service and its sub-features.
4.Select Microsoft .NET Framework 3.51 and its sub features.
5.Click OK.
Let’s Configure the Host Environment for the WCF Service to Support the TCP Protocol:

1.  Start inetmgr as administrator.

2.  Default site >> Right click >> Edit Bindings.

3.  If you have installed WAS correctly, it should list the default protocol bindings for the Web site, as shown in the following image:

Hosting WCF TCP Port

4.  Expand the Default Web Site item, and then click on your service (which is already hosted in IIS) application.

5.  Advanced Settings.

6.  In the Enabled Protocols add comma then net.tcp

Host WCF Service in WAS

7.  Click OK.

Now, Lets Configure the Client Application to Connect by Using the TCP Protocol.

  1. Test the service on the browser (copy paste the url to your browser) and make sure if it works.
  2. Now, Regenerate the proxy using the svcutil.exe
  3. Open the new output.config
  4. Get the new TCP Binding & endpoint from the file and add it to your client app.
    (The green bubbles below shows the net.tcp configuration).

5. Open the main() method in your client application and paste this line below:

ProductsServiceClient proxy = new ProductsServiceClient();

6. Run your app.

7. !!! What was that! Crash!

Note:
You have more than one endpoint available; you must specify which endpoint to use.

8. Just add your TCP endpoint’s name to your proxy constructor.

ProductsServiceClient proxy = new ProductsServiceClient(“NetTcpBinding_IService”);

TCP Endpoint name taken from:

10. Another Crash!! Go to the next step to solve that :).

11.Very important notes here:

  1. In most cases your machine will block the default TCP port; which is 808.
  2. For testing turn off your firewall.
  3. Add the port to the trusted ports:
  4. And to make sure that your Firewall will not block your port (if you do not turn it off); do the following:

i.     Go to Windows Firewall with advanced security.

ii.     And finally; add the port to Inbound Rules and Outbound Rules.