Note that there are some explanatory texts on larger screens.

plurals
  1. POError when moving from http to https on jquery ajax call to wcf service
    primarykey
    data
    text
    <p>I have a wcf service that is hosted in IIS 6.0 inside a .NET 3.5 web application and it is working fine over http, but when I try to implement https/ssl I get a 415 error back with the following error message. I am using json for both request and response.</p> <p>"Cannot process the message because the content type 'application/json' was not the expected type 'application/soap+xml; charset=utf-8'."</p> <p>Below is my client side jquery.ajax call, service contract and web.config. What am I missing here?</p> <p>Jquery.ajax call:</p> <pre><code> $.ajax({ type: "POST", url: "DataShare.svc/GetProgramsByEventType", data: '{"eventTypeIds": "' + eventTypeId + '"}', contentType: "application/json", dataType: "json", async: false, //async needs to be false to work with programs dropdown success: function (data, status) { var programs = data.GetProgramsByEventTypeResult; var html = ""; for (var i = 0; i &lt; programs.length; i++) { html += "&lt;li&gt;&lt;a href='#'&gt;" + programs[i].m_ProgramLongDesc + "&lt;span class='value'&gt;" + programs[i].m_ProgramID + "&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;" } $("#ddlProgramItems").html(html); }, error: function (request, status, error) { alert("Error - Status: " + request.status + "\nStatusText: " + request.statusText + "\nResponseText: " + request.responseText); } }); </code></pre> <p>WCF service contract:</p> <pre><code>&lt;ServiceContract()&gt; _ Public Interface IDataShare &lt;OperationContract()&gt; _ &lt;WebInvoke(Method:="POST", BodyStyle:=WebMessageBodyStyle.Wrapped, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json)&gt; _ Function GetProgramsByEventType(eventTypeIds As String) As List(Of WF.DataContracts.Program.Program) </code></pre> <p>web.config:</p> <pre><code> &lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="ServiceBehavior"&gt; &lt;serviceMetadata httpsGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="EndpointBehavior"&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="TransportSecurity" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647"&gt; &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;!--&lt;message clientCredentialType="Certificate" negotiateServiceCredential="true"/&gt;--&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;services&gt; &lt;service behaviorConfiguration="ServiceBehavior" name="DataShare"&gt; &lt;endpoint address="" binding="wsHttpBinding" contract="IDataShare" bindingConfiguration="TransportSecurity" behaviorConfiguration="EndpointBehavior"/&gt; &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;/system.serviceModel&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload