WCF Method Not Allowed in Visual Studio Integrated Web Server

I have two web projects in Visual Studio 2008 Service Pack 1 (SP1), one is hosting the WCF service, and the other I use to use the WCF service. The service in question provides the webHttpBinding endpoint and accepts JSON as input and returns JSON.

I used jquery ajax to use the service from a client web application as follows:

$(document).ready(function () {
    var data = '{"myobject":{"Business":"PIZZA"}}';
    $.ajax({
        type: "POST",
        contentType: "application/json",
        data: data,
        dataType: 'json',
        url: "http://localhost:1212/JobInfo.svc/ReturnThisString",
        error:
            function(XMLHttpRequest, textStatus, errorThrown) {
                alert("Error");
            },
        success: function(data) {
            alert("BoolValue: " + data.GetDataUsingDataContractResult.BoolValue);
            alert("StringValue: " + data.GetDataUsingDataContractResult.StringValue);
        }
    });

});

And I get the following error in the Firebug HTML request:

http://localhost:1212/JobInfo.svc/ReturnThisString 405 Method Not Allowed

But if you run the same file in the web project that hosts the project, it works fine.

localhost: 1212, localhost: RANDOM_PORT. localhost , , Cross Domain? ?

:

[OperationContract]
[WebInvoke(Method="POST",UriTemplate="ReturnThisString", 
        BodyStyle=WebMessageBodyStyle.Wrapped, 
        RequestFormat=WebMessageFormat.Json, 
        ResponseFormat=WebMessageFormat.Json)]
EventListArgs ReturnThisString(EventListArgs myobject);

[Serializable]
[DataContract]
public class EventListArgs {

    [DataMember( IsRequired = false)]
    public string Business;

    [DataMember( IsRequired = false)]
    public string Feeder;

}

:

public EventListArgs ReturnThisString(EventListArgs myobject)
{
    return myobject;
}

, - . , . , ( , ) JSON JSON.

enter image description here

, -, Visual Studio Built in web server ( IIS ). , , Darkside , , .

+3
1

IIS Express , IIS, . - , , . Casini , .

+2

All Articles