title: WCF POST Service 500 internal server error
body: <p>Here is the WCF POST Service with ajaxcallback. Its working fine on my side but not working on Client Side. It is giving error - POST <a href="http://localhost/WCFService/EService.svc/GetTIDFromRID" rel="nofollow">http://localhost/WCFService/EService.svc/GetTIDFromRID</a> 500 (internal server error).</p>
  
  <p>Method:</p>
  
  <pre><code>[OperationContract]
      [WebInvoke(Method = "POST",
                    RequestFormat = WebMessageFormat.Json,
                    ResponseFormat = WebMessageFormat.Json,
                    BodyStyle = WebMessageBodyStyle.WrappedRequest
                    )]
      string GetTIDFromRID(string RID);
  </code></pre>
  
  <p>Service Web.Config:</p>
  
  <pre><code>    &lt;system.diagnostics&gt;
      &lt;sources&gt;
        &lt;source name="System.ServiceModel.MessageLogging"&gt;
          &lt;listeners&gt;
            &lt;add name="messages"
            type="System.Diagnostics.XmlWriterTraceListener"
            initializeData="c:\logs\northwindservices.svclog" /&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt;
    &lt;/system.diagnostics&gt;
    &lt;system.serviceModel&gt;
      &lt;diagnostics&gt;
        &lt;messageLogging
                logEntireMessage="false"
                logMalformedMessages="true"
                logMessagesAtServiceLevel="true"
                logMessagesAtTransportLevel="false"
                maxMessagesToLog="500"
                maxSizeOfMessageToLog="5000"/&gt;
      &lt;/diagnostics&gt;
    &lt;/system.serviceModel&gt;
  
  
    &lt;system.web&gt;
      &lt;webServices&gt;
        &lt;protocols&gt;
          &lt;add name="HttpGet"/&gt;
          &lt;add name="HttpPost"/&gt;
        &lt;/protocols&gt;
      &lt;/webServices&gt;
          &lt;compilation debug="true" targetFramework="4.0"/&gt;
          &lt;authentication mode="None"&gt;&lt;/authentication&gt;
          &lt;pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/&gt;&lt;/system.web&gt;
      &lt;appSettings&gt;
          &lt;add key="ConStr" value="Data Source=C002;Initial Catalog=TEST;User ID=sa;Password=sa"/&gt;
      &lt;/appSettings&gt;
      &lt;system.serviceModel&gt;
  
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="EcubeBehavior"&gt;
                      &lt;serviceMetadata httpGetEnabled="true"/&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
              &lt;endpointBehaviors&gt;
                  &lt;behavior name="web"&gt;
                      &lt;!--&lt;webHttp/&gt;--&gt;
                      &lt;enableWebScript/&gt;
                  &lt;/behavior&gt;
              &lt;/endpointBehaviors&gt;
          &lt;/behaviors&gt;
  
      &lt;services&gt;
        &lt;service name="WCFService.EService" behaviorConfiguration="EBehavior"&gt;
          &lt;endpoint address="http://localhost/WCFService/EService.svc" behaviorConfiguration="web" binding="webHttpBinding" contract="WCFService.IEService"&gt;&lt;/endpoint&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost/WCFService/EService.svc"/&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
  
          &lt;standardEndpoints&gt;
              &lt;webScriptEndpoint&gt;
                  &lt;standardEndpoint name="" crossDomainScriptAccessEnabled="true"/&gt;
              &lt;/webScriptEndpoint&gt;
          &lt;/standardEndpoints&gt;
  
          &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"&gt;
          &lt;/serviceHostingEnvironment&gt;
  
      &lt;/system.serviceModel&gt;
      &lt;system.webServer&gt;
          &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
          &lt;directoryBrowse enabled="true"/&gt;
      &lt;/system.webServer&gt;
  </code></pre>
  
  <p>Service Consumption:</p>
  
  <pre><code>$.ajax({
          url: 'http://localhost/WCFService/EService.svc/GetTIDFromRID',
          data: JSON.stringify({ "RID": "r1234" }),
          dataType:  'json',
          type:   'POST',
          contentType:  'application/json; charset=utf-8',
          success: function (data) {
           },
          error: function (data) {
              alert('Response: Failed');
          }
      });
  </code></pre>
  
  <p>Please give some suggestion. Both Application and Service are hosted on different server. Permission is also given. Global.asax is also added which contains Header related code Access origin...</p>