Late blog (as in, not a live blog) Australia Power To Developers event

So there I was, sitting in the front row of the Power to Developers event in Sydney Convention Center.  A really great place by the way - it's like 5 minutes away from my home.

Steve Ballmer's presentation of Windows Azure is certainly very energetic.  He did the "Developers, Developers, Developers" chant - I cheered!

Gianpaolo Carraro's presentation on Windows Azure services was interesting, it certainly got my hands all itchy.  *Waiting for that SQL Data Services invite*

Tim Sneath's very excited about Windows 7, WPF and SilverLight.  I bumped into him outside the convention center and asked him about his visit to Sydney, in hindsight what I really should have asked him was which of these cool technologies should I spend all my time on?  How do I choose!

All the technical presentations were flaky, with the audience bursting out in laughter whenever Gianpaolo says "Oh Come On!"

I also got to meet heaps of people that I worked with over the last 3 years as well as some that were in SSW before that.

Shout outs:

the SSW crew,
David Klein, Adrian, Marlon
Ciprien, Ben Scott, Christian Maslen, Gordon Salier
Adelle, Peter

SharePoint, WCF Service, .NET full/partial trust

Security Exception: That assembly does not allow partially trusted callers

Scenario:

  1. We wanted our SharePoint webpart to do some complex logic that took time.
  2. We decided to implement it as an AJAX call to an AJAX WCF Service (see earlier post)
  3. To avoid cross-domain issues, we decided to host the WCF Service under SharePoint root.

The bigger picture looked like this:

  • SharePoint root: http://server/
  • WCF hosted on http://server/wcf.service/service.svc 
    Which we configure as a Web Application in IIS.
  • We build the WCF service separately and tested it to be working.
  • When we deployed to the SharePoint box however, we hit a snag when our WCF service calls an underlying API:

    Security Exception: That assembly does not allow partially trusted callers.

The cause:

What we understood of the problem basically was that the web.config for SharePoint http://server/web.config specified trust policies that mean anything under http://server/... was running with partial trust.

This isn't necessarily a bad thing, but because the API's we were calling demanded full trust, we couldn't proceed without granting the service full trust.

The fix:

There are many ways to grant the service full trust, we decided to do this by placing the service assembly into the GAC on the SharePoint server.

  1. Put assembly (strong-named) into the GAC
  2. Add <assembly> line into the web.config

If this option isn't available for you, check out caspol or the .NET configuration tools to elevate permission for your assembly.

Thoughts:

The deployment ended up to be very nice and tight:

SharePoint talks to the service via a SmartPart + jQuery.ajax

Done!

Windows Live Mail (Hotmail) has a nice new look

Most people probably have a Hotmail account, but like me, probably haven't visited it for quite a while.

Anyway, they unleashed a new version recently that looks a lot slicker.

(This is in Chrome)

image image

Very cool. 

I still think it misses the conversation threading view which is really fantastic in gmail, also I think tagging emails is still better than folders for organization.  But it's fast and snappy and doesn't require you to use IE for the full experience.

Consuming WCF WebService from jQuery AJAX (with JSON)

So the guys at work are pretty sold on jQuery now.  Everybody who've used it don't want to go back to vanilla JavaScript (just as I predicted).

One of the things always sitting at the back of my mind is to bridge the call from jQuery.ajax to WCF WebServices.

Finally we had a chance to do this, and it turns out this was pretty easy.  Special mention to Alvin Shen and Ron Maman who checked this out.

 

  1. Create an AJAX-enabled WCF WebService
    image
  2. This will update your web.config - the only difference is the WCF bindings used - here are the two interesting bits

    <service name="SSW.WCF.Services.BookService">
       <endpoint address="" behaviorConfiguration="SSW.WCF.Services.BookServiceAspNetAjaxEndPointBehavior"
        binding="webHttpBinding" contract="SSW.WCF.Services.BookService" />
    </service>

    <behaviors>
       <endpointBehaviors>
          <behavior name="SSW.WCF.Services.BookServiceAspNetAjaxEndPointBehavior">
             <enableWebScript />
          </behavior>
       </endpointBehaviors>
    </behavior>

  3. Here's the jQuery AJAX call

    $(document).ready(function() {
        $.ajax({
            type: "POST",
            url: http://localhost/<web app name>/BookingService.svc/DoWork,
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
                alert(data.d);

            }
        });
    });

 

Incredibly easy, the hardest part was working what the url was going to be

 

UPDATE technologies list:

  • jQuery
  • WCF WebService (AJAX-enabled WCF WebServices are only available in ASP.NET 3.5 - where they added the webHttpBinding, which does JSON serialization)

UPDATE:
Note that ASP.NET does date serialization a bit differently - there is no proper JSON date standard, and the JavaScript date doesn't match the .NET DateTime class with timezone, you may need to do a bit of work to serialize back to a JavaScript date. 

 

Here's a fun service that we use for testing.

// Add more operations here and mark them with [OperationContract]
[OperationContract]
public object[] TestJSON()
{
    return new object[] { DateTime.Now, 1, 1.034f, null, "test" };
}

Seriously thinking to split this blog

I like blogging about what I'm doing, but in some aspect, there are different areas that I would like to blog about:

Software Development

  • Some really interesting problems and how we solve them
  • Some really annoying bugs and how we got around them
  • Some totally unexplained and undocumented feature and how we figured out how it all worked

Software Project Management

  • This is not my forte, but as you get experienced in this industry it's probably inevitable that you end up doing project management work
  • Project management deals a lot with the risks, processes and communication with clients.

Gaming

  • What I thought about WOW
  • What I'm thinking about WAR
  • XBox, XBox Live
  • PC gaming, in general

Rants

  • Stuff that happens, usually something about my laptop - honestly if my laptop was working fine you guys would never even know I was using a Dell Studio 17 (BTW, after the technician fixed it, it's working really well now)