[WebInvoke]why not call fail? RRS feed

  • Question

  • Hi,

    I'm are making a Web service using WCF.

    to the service by using the webHttpBinding,
    I do not know what to write [WebGet], to [WebInvoke] in the WCF. Big difference between the two is what?

    If [WebGet], by using the JSON AJAX
    I've been successfully import the data.

    It has continued to fail in the case of [WebInvoke] "POST".
    And the attempt to overcome together the parameter to WebInvoke even look when viewed by searching the relevant information, to the attempt to pass without parameter.

    Why is that? :(
    Why not, and very frustrating. Please give me advice and related information.

    ERROR: "Bad Request"

    WCF server code


    Client code
    //Call JSONP 
                    cache: false,
                    url: "http://localhost:61030/Service1.svc/GetPeopleJson",
                    data: '{"players" : "Apple" , "position" : "SW"}',
                    type: "POST",
                    jsonpCallback: "MyCallback",
                    contentType: "application/javascript",
                    dataType: "jsonp",
                    error: function (err) {
                        alert("list failed!" + err.statusText);
                    success: function (list) {
                          $.each(list, populateDropdown); // must call function as var
                        for (var i = 0; i < list.length; i++) {


    Web.Config Code

            <behavior name="WebServiceBehavior">          
              <serviceMetadata httpGetEnabled="true"/>          
              <serviceDebug includeExceptionDetailInFaults="true"/>

            <behavior name="jsonBehavior">
              <webHttp helpEnabled="true"/>
          <service behaviorConfiguration="WebServiceBehavior" name="DataService.Service1">        
            <endpoint address="" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" bindingConfiguration="webHttpBindingJsonP" contract="DataService.IService1" />
            <endpoint address="soap" binding="basicHttpBinding" contract="DataService.IService1" />        
            <binding name="webHttpBindingJsonP" crossDomainScriptAccessEnabled="true"/>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />    


    fiddler config

    POST http://localhost:61030/Service1.svc/GetPeopleJson HTTP/1.1
    Accept: text/javascript, application/javascript, */*
    Content-Type: application/javascript
    Referer: http://localhost:61032/Default.aspx
    Accept-Language: ko-KR
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/5.0 (compatible; MSIE 9.0;IPMS/56CC6F0A-1518A03E8A8-00000120365D; Windows NT 6.1; WOW64; Trident/6.0)
    Connection: Keep-Alive
    Content-Length: 61
    DNT: 1
    Host: localhost:61030
    Pragma: no-cache
    Cookie: ASP.NET_SessionId=ta0g3w3tzhq0zunxgybnbdwz

    {"players" : "Apple" , "position" : "SW"}&callback=MyCallback


    THX :D

    Monday, May 13, 2013 12:31 AM


All replies