I have a wcf service hosted in IIS 6.0 inside a .NET 3.5 web application and it works fine on http, but when I try to implement https / ssl, I get 415 error with the following error message. I use json for request and response.
"The message cannot be processed because the content type 'application / json' was not the expected type 'application / soap + xml; charset = utf-8'."
Below is my client jQuery.ajax call, service contract and web.config. What am I missing here?
Jquery.ajax call:
$.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 < programs.length; i++) { html += "<li><a href='#'>" + programs[i].m_ProgramLongDesc + "<span class='value'>" + programs[i].m_ProgramID + "</span></a></li>" } $("#ddlProgramItems").html(html); }, error: function (request, status, error) { alert("Error - Status: " + request.status + "\nStatusText: " + request.statusText + "\nResponseText: " + request.responseText); } });
WCF Service Contract:
<ServiceContract()> _ Public Interface IDataShare <OperationContract()> _ <WebInvoke(Method:="POST", BodyStyle:=WebMessageBodyStyle.Wrapped, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json)> _ Function GetProgramsByEventType(eventTypeIds As String) As List(Of WF.DataContracts.Program.Program)
web.config:
<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceMetadata httpsGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="EndpointBehavior"> </behavior> </endpointBehaviors> </behaviors> <bindings> <wsHttpBinding> <binding name="TransportSecurity" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </wsHttpBinding> </bindings> <services> <service behaviorConfiguration="ServiceBehavior" name="DataShare"> <endpoint address="" binding="wsHttpBinding" contract="IDataShare" bindingConfiguration="TransportSecurity" behaviorConfiguration="EndpointBehavior"/> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel>
source share