SharePoint 2010 WCF HelloWorld Service and InfoPath

Was looking for a quick tutorial for creating a Custom WCF Service for SharePoint 2010.  For some reason couldn’t find one, so I sat down and try it out and decide to write out a few simple steps.

Use CKSDev version 1.2 included new Visual Studio Item templates for creating WCF services and makes this whole process a breeze.  Thanks to Charlie Holland’s hardwork.


Build Solution

  1. Create New Blank VS.NET SharePoint Solution “HelloWorldWCF”
  2. WCF Service has to be a Farm Solution.
  3. Add New Item, and select WCF Service (CKSDev)image
  4. The created Service includes a stub method that returns a string.

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class HelloWorldWCFService : IHelloWorldWCFService
        // To test this service, use the Visual Studio WCF Test client
        // set the endpoint to http://<Your server name>/_vti_bin/HelloWorldWCF/HelloWorldWCFService.svc/mex
        public string HelloWorld()
            return "Hello World from WCF and SharePoint 2010";
  5. Compile solution and Deploy to server

Verify Service

  1. The service is deployed to /_vti_bin/HelloWorldWCF/HelloWorldWCFService.svc
  2. The endpoint is at http://server/_vti_bin/HelloWorldWCF/HelloWorldWCFService.svc/mex
  3. Browse it with your browser you should see:



Connect Via InfoPath

  1. Create an External Connection
  2. Select SOAP Service, use the /mex endpoint
  3. You may be asked to authenticate with the service
  4. Select the method

  5. Cache, and Retrieve when form load as necessary.

  6. Bind the result of the web service to a textbox



Test in InfoPath

  1. Preview the InfoPath form