none
Content type type 'application/soap+msbin1'. RRS feed

  • Question

  • Hi,

    I am calling WCF service from JQURY and i am getting error

    Cannot process the message because the content type 'application/json; charset=UTF-8' was not the expected type 'application/soap+msbin1'.

    Below is my code calling WCF service.

       

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>

    </head>
    <body>
        <div style="margin: 10px auto;">
            <input type="button" value="Accept" id="btnAccept" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Reject" id="btnReject" />
        </div>
    </body>
    <script>
        $('#btnAccept').click(function () {

            debugger;
            $.ajax({

                url: "http://localhost:8090/IFormEdmontonService.svc/QueryFormOP14ById",
                data: JSON.stringify({ 'id': 5}),
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    alert(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(textStatus);
                }
            });
        });
    </script>

    </html>

    WCF Code:

     [OperationContract]
            [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,RequestFormat=WebMessageFormat.Json)]
            FormOP14 QueryFormOP14ById(long id);

    Service.cs:

     [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
        [AspNetCompatibilityRequirements(RequirementsMode= AspNetCompatibilityRequirementsMode.Allowed)]//Added by ppanigrahi
        public class FormEdmontonService : IFormEdmontonService

    web.config:

    <!--diagnostics performanceCounters="All" /-->
        <!--DEFINE YOUR SERVICES WITH ENDPOINTS-->
        <!--<services>
          <service name="IFormEdmontonService" behaviorConfiguration="MyServiceBehavior">

            <endpoint address="" binding="webHttpBinding"
               behaviorConfiguration="webEndPointBehavior"
               name="webEndPoint"
               contract="IFormEdmontonService"/>
          </service>
        </services>

        <behaviors>
          --><!--SERVICE BEHAVIORS--><!--
          <serviceBehaviors>
            <behavior name="MyServiceBehavior">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>

          --><!--ENDPOINT BEHAVIORS--><!--
          <endpointBehaviors>
            <behavior name="webEndPointBehavior">
              <webHttp />
            </behavior>
          </endpointBehaviors>
        </behaviors>-->


    Thursday, December 19, 2019 4:28 PM