SP2013 Custom services deploys and runs on v15

 

I fired up my SP2013 VM to do some simple tests tonight, I wanted to know if the REST services that I've built and demo'ed for SharePoint 2010 would run in SP2013.  Technically, they should.

So I deployed:

  • stsadm -o addsolution -filename .\SPGSvcWp.wsp
  • stsadm -o deploysolution -name SPGSvcWp.wsp -local -allowgacdeployment -allcontenturls

 

The files are copied to the services OK.

Deployed to ISAPI folder (_vti_bin)

image

 

DataService

image

 

REST service

image

SOAP service

image

 

Activate the features for the webpart:

image

 

Add the Web Part to the page:

image

 

The javascript needs a small modification - since the page in 2013 is loaded asynchronously.  But once I've re-attached the click event, the REST service itself works fine and returns the properties of the selected item.

The SharePoint Pinterest-style Image Library

A picture is worth a thousand words.

 

In the latest version of spaspa.codeplex.com, I created a separate Knockout Template and bind the Images library (BaseTemplateID 851) to it.  Then I inserted a simple jQuery Plugin Wookmark https://github.com/GBKS/Wookmark-jQuery

The end result is that when we have pictures, they are displayed in an awesome layout.

As an added bonus, I'm calculating the thumbnail image from SharePoint, so instead of rendering:

http://spg-dev-jl/PublishingImages/wallpaper_08.jpg

image

Original: 78K

I'm rendering

http://spg-dev-jl/PublishingImages/_w/wallpaper_08_jpg.jpg

image

Thumbnail image generated by SharePoint.  Which is a far smaller file - 16k.

 

Next update, I'll try to resolve those pesky SharePoint users and get the correct user name and picture.  So we don't have Mr. Bill Gates staring back at us! ;-)

Test your C#: Generic overloaded constructors

I love languages.  Here's one for a language nut.

public class Response<T> {

    private T result;
    private string error;

    public Response(T result) { this.result = result; }
    public Response(string message) { this.error = message; }

}

 

You can use this generic class as a wrapper for returning data.

return new Response<int>(1000);

Or to return an abnormal result

return new Response<int>("Something has gone wrong");

 

Question 1

The fun part then, is what happens when you have this?

var result = new Response<string>("Is this a result or an error?");

What is result

 

Question 2


What about this:

public class Sample
{
    public static Response<T> GetSample<T>(T arg)
    {
        return new Response<T>(arg);
    }
}

and then:

var result = Sample.GetSample("Is this an error?");

What is result

SharePoint Saturday Adelaide update

 

Hope you enjoyed the session and all the wonderful sessions through out the day.

I hope I've also given you plenty of ideas on how you can mix and match a really rich set of the latest technology in your SharePoint environment. 

A summary link of all my related talks on REST, services and JavaScript technologies like jQuery and Knockout are on /rest/

A direct link to the solution that I used for the demo is at: https://static1.squarespace.com/static/5527bff2e4b0b430660b0d10/5527c30de4b030eeeef09715/5527c30ee4b030eeeef09b23/1316868647487/SPGSvcWp.zip

The PowerPoint presentation is at: https://static1.squarespace.com/static/5527bff2e4b0b430660b0d10/5527c30de4b030eeeef09715/5527c30ee4b030eeeef09b24/1335084544036/SharePoint+REST+and+jQuery5.pptx

Drop me a question if you want to ask me anything specific related to these topics and I'm more than willing to geek out!  Hope to see you guys again soon.

You can find me via

T: @johnnliu
E: john.liu at sharepointgurus.net

Or grab a business card from me throughout the day!