jackjohnson44
asked on
.net wcf web service 400 bad request
I am stuck. I am trying to make a wcf web service on my sharepont 2010 site. I created my web service using a cksdev visual studio plugin that creates the file for you. I had a more complex sample, but it wouldn't work, so I created a new one straight out of the box that returns a "hello world".
I am calling it from jQuery and keep getting a 400 bad request response that I can see in fiddler.
If I try an incorrect url, I get a file not found error, so I know that the web service exists. I can't step into code and have no idea how to diagnose this.
I am calling it from jQuery and keep getting a 400 bad request response that I can see in fiddler.
If I try an incorrect url, I get a file not found error, so I know that the web service exists. I can't step into code and have no idea how to diagnose this.
my svc.cs file
[BasicHttpBindingServiceMetadataExchangeEndpoint]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class WCFService1 : IWCFService1
{
// To test this service, use the Visual Studio WCF Test client
// set the endpoint to http://<Your server name>/_vti_bin/Fmg.Extranet.ContextSelector.UI/WCFService1.svc/mex
public string HelloWorld()
{
return "Hello World from WCF and SharePoint 2010";
}
}
My .svc file
<%@ ServiceHost Language="C#" Debug="true"
Service="MYASSEMBLYNAME.WCFService1, $SharePoint.Project.AssemblyFullName$"
CodeBehind="WCFService1.svc.cs"
Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
My IWCFService1.cs file
[ServiceContract]
public interface IWCFService1
{
[OperationContract]
string HelloWorld();
}
My jQuery
$.ajax({
url: "http://affiliatedfmonline/_vti_bin/Fmg.Extranet.ContextSelector.UI/WCFService1.svc/HelloWorld",
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
},
success: function (data, textStatus, jqXHR) {
alert("success");
response($.map(data, function (item) {
return {
label: item.Name,
value: item.ID,
desc: item.Location
}
}));
}
});
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the domain/port/protocol are the same?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
leakim, I don't understand the question. The url that I am using is correct.
gopal. I added that and am still getting the same error.
gopal. I added that and am still getting the same error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My solution was correct
ASKER
Also, the issue is with the request, not the response.
Any other suggestions?