1

I have looked at several posts on SO which are showing how to add multiple endpoints for same service, but non of them is actually using HTTPS, which is why I am asking this question.

What I have

I have a web service,

https://portal.gov.com/us/216/_vti_bin/external/gov.svc

What I want

I want to call this web services using two different configurations, and bindings with different ENDPOINTS but SAME URL ?. (Sorry maybe I am confused with concept of EndPoints)

Here is what my web.config looks like,

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Gov_ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <bindings>
      <webHttpBinding>
        <binding name="Gov_webHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="InheritedFromHost" />
          </security>
        </binding>
      </webHttpBinding>
      <!--<basicHttpBinding>
        <binding name="Gov_BasicHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="InheritedFromHost" />
          </security>
        </binding>
      </basicHttpBinding>-->
    </bindings>

    <services>
      <service name="Portal.WebServices.External.Gov" behaviorConfiguration="Gov_ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="Portal.WebServices.External.IGov" bindingConfiguration="Gov_webHttpBinding"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        <!--<endpoint address="basic" binding="basicHttpBinding" contract="Portal.WebServices.External.IGov" bindingConfiguration="Gov_BasicHttpBinding"/>-->
      </service>
    </services>

  </system.serviceModel>

</configuration>

WHERE IS THE PAIN

IT only works until I keep basicHttpBinding commented out and it's endpoint, as soon as I include it, I get silent error.

According to this - https://msdn.microsoft.com/en-us/library/ms751515(v=vs.110).aspx

It should work, but it doesn't maybe because I am using HTTPS and adding BINDINGS tag to my web.Config

Mathematics
  • 7,314
  • 25
  • 77
  • 152
  • I don't think `WebHttpBinding` is consider similarly to `BasicHttpBinding` or so.When one builds a restful wcf service , needs to use `WebHttpBinding`.And no `MetaData` is exposed for consumption. – Amit Kumar Ghosh Jul 21 '15 at 12:39
  • `HTTPS` is definitely not the case here, but the way you're exposing your service , i.e. the bindings combination you choose might not work side by side.Can you try removing the `WebHttpBinding` and add another `WsHttpBinding` instead to see what happens. – Amit Kumar Ghosh Jul 21 '15 at 12:45
  • In case of `WebHttpBinding` no MetaData is exposed for consumption. – Amit Kumar Ghosh Jul 21 '15 at 12:50
  • see http://stackoverflow.com/questions/14403492/cannot-process-the-message-because-the-content-type-application-json-charset-u – Amit Kumar Ghosh Jul 21 '15 at 13:10
  • @AmitKumarGhosh I am sorry but I don't think you understand the issue in the question, thanks for trying though. – Mathematics Jul 21 '15 at 13:11
  • I can understand your problem, but are you considering my inputs? – Amit Kumar Ghosh Jul 21 '15 at 13:13

1 Answers1

0

What you are trying to achieve is impossible. You can't apply two different bindings with exactly the same Endpoint. If you try to read again your reference here it is clear that the sample has two different endpoints :

First address is http://localhost/servicemodelsamples/service.svc and the second is http://localhost/servicemodelsamples/service.svc/secure. These two endpoints are different to each other but share with same contract.

The second endpoint is just relative to the base address http://localhost/servicemodelsamples/service.svc.

I hope this make your mind clear about binding and endpoint.

jtabuloc
  • 2,479
  • 2
  • 17
  • 33