none
Creating Custom WCF in sharePoint 2013 RRS feed

  • Question

  • Hello,

    I create the following WCF for sharepoint :

        [ServiceContract]
        public interface IMyService
        {
            [OperationContract]
            [WebGet(UriTemplate = "GetData?value={value}", ResponseFormat = WebMessageFormat.Json)]
            string GetData(string value);

       }

    ----------------------------------------------------

    [ServiceBehavior]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
        public class MyService : IMyService
        {
            public string GetData(string value)
            {
                return string.Format("You entered: {0}", value);
            }

    }

    ------------------------------------------------------------------------------

    <%@ ServiceHost Language="C#" Debug="true" Service="VS2012WcfService.MyService, $SharePoint.Project.AssemblyFullName$" CodeBehind="MyService.cs" %>

    -----------------------------------------------------------------------------------

    in the web.config , I use the  binding "wsHttpBinding" .

    when I type the url on the browser "http://serverName:9090/_vti_bin/MyService/MyService.svc/GetData?value=20" , it doesnot return any values.

    so waht is wrong?


    ASk

    Monday, June 23, 2014 9:16 AM

Answers

  • Hi,

    According to your post, my understanding is that you wanted to create a WCF service in SharePoint 2013.

    There is an article about creating a WCF service with details steps.

    You can check your steps with the below article, I had tested with it, it worked like a charm.

    http://www.sharepointpals.com/post/Step-by-Step-Procedures-to-create-a-WCF-Service-Application-for-SharePoint-2013

    Thanks & Regards,

    Jason

    Jason Guo
    TechNet Community Support

    • Marked as answer by Lindali Sunday, July 6, 2014 4:26 AM
    Tuesday, June 24, 2014 9:43 AM
  • hi

    you try to access .svc file from _vti_bin virtual folder (http://serverName:9090/_vti_bin/MyService/MyService.svc). This virtual folder is mapped to the 14/isapi folder on the file system of the front end server (similar to the _layouts virtual folder which is mapped to 14/layouts). I.e. if you want to access your WCF service from there you need to copy svc file to 14/isapi/MyService folder first. Note that it has own web.config which will override settings defined in the web.config which is located in the root virtual folder of your web application in c:/inetput/wwwroot/wss/VirtualDirectories/... . Alternatively you may use _layouts virtual folder for uploading your svc service, like you upload regular application layouts pages (it is used more frequently for installing customizations than _vti_bin). In this case you will access WCF service by the following url: http://serverName:9090/_layouts/MyService/MyService.svc (assuming that svc file will be in MyService subfolder).


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    • Marked as answer by Lindali Sunday, July 6, 2014 4:26 AM
    Tuesday, June 24, 2014 9:58 AM

All replies

  • Hi,

    According to your post, my understanding is that you wanted to create a WCF service in SharePoint 2013.

    There is an article about creating a WCF service with details steps.

    You can check your steps with the below article, I had tested with it, it worked like a charm.

    http://www.sharepointpals.com/post/Step-by-Step-Procedures-to-create-a-WCF-Service-Application-for-SharePoint-2013

    Thanks & Regards,

    Jason

    Jason Guo
    TechNet Community Support

    • Marked as answer by Lindali Sunday, July 6, 2014 4:26 AM
    Tuesday, June 24, 2014 9:43 AM
  • hi

    you try to access .svc file from _vti_bin virtual folder (http://serverName:9090/_vti_bin/MyService/MyService.svc). This virtual folder is mapped to the 14/isapi folder on the file system of the front end server (similar to the _layouts virtual folder which is mapped to 14/layouts). I.e. if you want to access your WCF service from there you need to copy svc file to 14/isapi/MyService folder first. Note that it has own web.config which will override settings defined in the web.config which is located in the root virtual folder of your web application in c:/inetput/wwwroot/wss/VirtualDirectories/... . Alternatively you may use _layouts virtual folder for uploading your svc service, like you upload regular application layouts pages (it is used more frequently for installing customizations than _vti_bin). In this case you will access WCF service by the following url: http://serverName:9090/_layouts/MyService/MyService.svc (assuming that svc file will be in MyService subfolder).


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    • Marked as answer by Lindali Sunday, July 6, 2014 4:26 AM
    Tuesday, June 24, 2014 9:58 AM