Link to home
Start Free TrialLog in
Avatar of jackjohnson44
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.


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
                            }
                        }));
                    }
                });

Open in new window

SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jackjohnson44
jackjohnson44

ASKER

I just did and no luck.   That was actually from a more complicated sample.  I was at first returning a json object that was a seralized list collection and passed parameters in.  When I had difficulty, I removed the parameters and just tried to return a string.

Also, the issue is with the request, not the response.

Any other suggestions?
the domain/port/protocol are the same?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My solution was correct