Contents
Applies to: Business Connectivity Services | Open XML | SharePoint Designer 2010 | SharePoint Foundation 2010 | SharePoint Online | SharePoint Server 2010 | Visual Studio This article describes how to call an authenticated Windows Communications Foundation (WCF) service from the SharePoint online sandbox web part by using the jQuery Ajax method.
How to publish a WCF service to a web application?
To publish the service to the web application you just created, use the publishing features of Microsoft Visual Studio. Perform the following steps to publish the service. Right-click the WCF service application project and then click on Publish. Select File System as the publish method.
How to create a WCF service in Visual Studio?
Because you use the JSONP binding for the web service, you must first set up the JSONP binding library. Next, you set up the WCF Service Application project. Create an empty Visual Studio solution. Right-click the solution in Solution Explorer and then click Add new project.
When to use SVC file in WCF project?
Once you have created the new WCF service application project, templates are added for the service interface, as well as the SVC file and web configuration files. An SVC file is used by WCF to represent a service hosted by IIS. In the next procedure, you implement an operation contract to support the scenario.
Right-click on the ISAPI folder in the Solution Explorer, then Add -> New Item . On the Add New Item dialog, select Interface from the Code category and enter IPresidentsService.cs as the name, then click Add. Add the required assembly references by right-clicking References, then Add Reference from the Solution Explorer.
How to call a WCF service in jQuery?
Note: Endpoint settings done in the config works in conjunction with the WebInvoke attribute of the operation and the compatibility attribute set in ServiceType to support HTTP requests sent by jQuery. To consume a web service using jQuery, that is to make a call to the WCF service, you either use jQuery.ajax () or jQuery.getJSON ().
How to create WCF service in ASP.NET?
Once you are done with creating the WCF service, you need to specify the attributes on the server type class for ASP.NET compatibility mode, so that the WCF service works as a normal ASMX service and supports all existing ASP.NET features.
Can a WCF service be hosted on IIS?
By setting compatibility mode, the WCF service will have to be hosted on IIS and communicate with its client application using HTTP. Read more about this in detail here: WCF Web HTTP Programming Object Model.
How to call a cross domain WCF service?
Name the site ContosoDataService. Select the application pool that you just created. In Visual Studio, specify the physical path to publish the WCF binaries. In the binding section, set the Protocol to HTTPS and the port to 4431 (or any other free port).