11

We have a webservice that works fine on HTTPS but shows the HTTP 415 error on HTTPS. So, under HTTP, we can make a POST request sending and receiving JSON without issue. When we try the same under HTTPS we got the error that the service is expecting text/xml insteas of application/json. Any suggestion on where to look?

The server is using a self signed certificate if that matters.

Updated with bindings and behaviors

 <!-- Wcf Services Setting --> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WsHttpBinding" maxReceivedMessageSize="1048576"> <readerQuotas maxArrayLength="1048576" /> </binding> <binding name="SecureWsHttpBinding" maxReceivedMessageSize="1048576"> <readerQuotas maxArrayLength="1048576" /> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </wsHttpBinding> <webHttpBinding> <binding name="WebHttpBinding" maxReceivedMessageSize="1048576"> <readerQuotas maxArrayLength="1048576" /> </binding> <binding name="SecureWebHttpBinding" maxReceivedMessageSize="1048576"> <readerQuotas maxArrayLength="1048576" /> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> <binding name="webBinding"> <security mode="Transport"> </security> </binding> </webHttpBinding> <basicHttpBinding> <binding name="BasicHttpBinding_IMainService" maxReceivedMessageSize="1048576"></binding> <binding name="BasicHttpBinding" maxReceivedMessageSize="1048576"> <readerQuotas maxArrayLength="1048576" /> <security mode="None"> <transport clientCredentialType="None" /> </security> </binding> <binding name="SecureBasicHttpBinding" maxReceivedMessageSize="1048576"> <readerQuotas maxArrayLength="1048576" /> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </basicHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="AjaxBehavior"> <webHttp DefaultOutgoingResponseFormat="json" /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="DvaMfs.WcfService"> <useRequestHeadersForMetadataAddress> <defaultPorts> <add scheme="https" port="443" /> </defaultPorts> </useRequestHeadersForMetadataAddress> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> 

services look like this

<service name="DvaMfs.WcfService.ProductService" behaviorConfiguration="DvaMfs.WcfService"> <endpoint name="ProductServiceEndPoint" address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding" contract="DvaMfs.WcfService.IProductService" /> <endpoint name="ProductServiceAjaxEndPoint" address="ajax" binding="webHttpBinding" bindingConfiguration="WebHttpBinding" behaviorConfiguration="AjaxBehavior" contract="DvaMfs.WcfService.IProductService" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <endpoint name="ProductServiceSecureEndPoint" address="ProductServiceSecure" binding="basicHttpBinding" bindingConfiguration="SecureBasicHttpBinding" contract="DvaMfs.WcfService.IProductService" /> <endpoint name="ProductServiceAjaxSecureEndPoint" address="ProductServiceSecureajax" binding="webHttpBinding" bindingConfiguration="SecureWebHttpBinding" behaviorConfiguration="AjaxBehavior" contract="DvaMfs.WcfService.IProductService" /> </service> 

Update 2 This is one of the endpoints failing:

<endpoint name="DataServiceSecureEndPoint" address="" binding="basicHttpBinding" bindingConfiguration="SecureBasicHttpBinding" contract="DvaMfs.WcfService.IDataService" /> 
8
  • Assuming you're using WCF, please provide the bindingConfiguration and behaviors. This is the key of you're error, I think Commented Oct 29, 2014 at 8:04
  • BTW, I tried all the suggestions for all the questions with this same error on SO without any luck. Commented Oct 29, 2014 at 8:33
  • @CapitanCavernícola Updated the question with part of config file. Commented Oct 29, 2014 at 8:35
  • Which EndPoints are failing? Commented Oct 29, 2014 at 8:59
  • 1
    Maybe you can "comment" all the endpoints but 'ProductServiceAjaxSecureEndPoint', to be sure you're using it. Commented Oct 29, 2014 at 9:24

5 Answers 5

10

WCF can have different endpoints for HTTP or HTTPs. I think this is the problem, so I will put it as an "answer" (I hope it helps you):

Your endpoint name="ProductServiceEndPoint" address="" it's exposed at your base address. OK

Your endpoint name="ProductServiceSecureEndPoint" address="ProductServiceSecure" bindingConfiguration="SecureBasicHttpBinding" it's exposed at base "base_address]/ProductServiceSecure".

So this endpoint:

  • endpoint name="DataServiceSecureEndPoint" address="" binding="basicHttpBinding" bindingConfiguration="SecureBasicHttpBinding"

It's incorrect, because the address may be "ProductServiceSecure"

Sign up to request clarification or add additional context in comments.

1 Comment

It makes sense, I am accepting it hoping it will help someone else with this problem in the future. Saludos ;-)
2

The basicHttpBinding can not work with JSON. Change the basicHttpBinding (SOAP) to webHttpBinding (REST) if you want to use JSON.

3 Comments

Then how would you explain that the same exact code works fine with JSON on HTTP? This problem only happens when doing the POST with HTTPS. I can't understand why
I would say your are examining the wrong endpoint or the call to the sarvice isn't requesting json because the basicHttpBinding never supported json at all.
Same exact code can't be, I suppose you're setting the proxy anyway. For more testing: Could you try the place 'only' <webHttp/> instead of '<webHttp DefaultOutgoingResponseFormat="json" />', and comment the endpoint that you're not using in HTTPS ?
1

For this problem solution is that, In your request/response model there is some class who have not by default constructor which is parameterless.

Comments

0

At the end our back-end developer changed the endpoint address field and routed it to specific paths (instead of address="") to test if it was working and it was. Apparently, according to what he said, the HTTP and HTTPS endpoints were trying to use the same address and that wasn't working. So he finally commented the HTTP endpoints and set the address for the HTTPS ones.

I don't know if that make much sense since I have no idea about WCF. To me, having some knowledge on Apache servers, it seems that you should be able to specify an endpoint and it shouldn't be based on/linked to the protocol used for connecting to it.

Comments

0

In configfile add in service tag name="namespace.Service" then in endpoint tag

address="" behaviorConfiguration="web" binding="webHttpBinding" contract="namespace.IService" 

and in IService interface

[WebInvoke(Method = "POST", UriTemplate = "functionname", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.