Problem Statement:-
I was getting the error 400 Bad Request, when trying to call the WCF web service using AJAX or from SharePoint 2013 Workflow.
Solution:-
I have figured out the issue and resolved by the following code:
- In your service Interface where you will define the OperationContact, you need to use the WebInvoke with the following Method = “GET” or “POST” depends upon your requirement, ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Bare.
Example:-
[OperationContract]
[WebInvoke(Method = “GET”,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
string HelloWorld();
2. Add Factory=”System.ServiceModel.Activation.WebScriptServiceHostFactory” in the .svc file like this:
<%@ ServiceHost Language=”C#” Debug=”true” Service=”WcfService1.Service1″ CodeBehind=”Service1.svc.cs” Factory=”System.ServiceModel.Activation.WebScriptServiceHostFactory” %>
Download the Source code:-
First rename the above .doc file to .zip and extract it