1

Iam trying to configure a service for access over both https and http from a silverlight 4 application. I am able to access the service over https but not over http. I have made some research over the net but can't seem to get the configuration right.

Below is my current settings in the my web.config file.

    <system.serviceModel>

    <bindings>
      <customBinding>
          <binding name="MyhttpsBinding">
          <binaryMessageEncoding/>
          <httpsTransport/> 
          </binding>
          <binding name="MyhttpBinding">
              <binaryMessageEncoding/>
              <httpTransport/>
          </binding>
      </customBinding>
    </bindings>

    <services>
      <service name="MyData" behaviorConfiguration="MyData">
        <endpoint address="" binding="customBinding" bindingConfiguration="MyData.customBinding.https" contract="MyData"/>
        <endpoint address="" binding="customBinding" bindingConfiguration="MyData.customBinding.http" contract="MyData"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyData" >
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
        </behavior>
        <behavior name="">
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
  </behaviors>

  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>

And below is my ServiceReferences.ClientConfig file

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="DataS" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
            <binding name="DataS1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
        <customBinding>
            <binding name="CustomBinding_GetData">
                <binaryMessageEncoding />
                <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            </binding>
        </customBinding>
    </bindings>

    <client>
        <endpoint address="//localhost/MyApp/Webservice/Data.asmx"
            binding="basicHttpBinding" bindingConfiguration="DataS1"
            contract="ServiceReference1.DataS" name="DataS" />

        <endpoint address="//localhost/MyApp/Webservice/GetData.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_GetData"
            contract="GetData.GetData" name="CustomBinding_GetData" />
    </client>

</system.serviceModel>

What do i have mis-configured above that is making the calls to the service fail on http.

StackTrace
  • 9,190
  • 36
  • 114
  • 202
  • You've checked directly against the service endpoint (via browser, not silverlight app) and it won't load in HTTP? To be certain, you are not decorating your service class in code with any security attributes, correct? – Mike Guthrie Jul 31 '14 at 17:08
  • Checking directly against the service endpoint via browser works for both http & https – StackTrace Apr 24 '15 at 06:32
  • I believe Silverlight hosted from https will simply not call a http service. Like when you are browsing a site on https, but some site content is from http, the browser pops up that warning message. For Silverlight, it sees the same vulnerability, and simply doesn't make the request. You can try to get more detail by monitoring network traffic with the app open. Run your Silverlight, open the browser debugger tools, and look for your expected service calls. – Mike Guthrie Apr 24 '15 at 15:40

1 Answers1

0

Add one more endpoint with mexHttpBinding as below endpoint address="mexhttp" binding="mexHttpBinding" contract="IMetadataExchange"/>

and also

add the service behavior to the service tag

<service name="MyData" behaviorConfiguration="MyData">
Vinod Kumar
  • 137
  • 1
  • 10
  • are you done with your problem? if not please show the latest configuration file – Vinod Kumar Aug 05 '14 at 04:19
  • i have updated my post with my current (latest) web.config and ServiceReferences.ClientConfig settings. I still cannot access the service via http but every works well over https. And i have a requirement to support both https and http. – StackTrace Aug 05 '14 at 06:19
  • Change the mex endpoint name of http endpoint and change the name of bindingConfiguration of your endpoint as MyhttpBinding and the contract should be the interface(service contract) – Vinod Kumar Aug 05 '14 at 08:16
  • browse the service with base address with mexhttp endpoint like : http:// localhost:234/Myservice/Mexhttp(the name of your mexhttp endpoint) – Vinod Kumar Aug 05 '14 at 08:20
  • if possible share your solution to vinod.profileinfo@gmail.com, wil try to resolve that – Vinod Kumar Aug 05 '14 at 08:21
  • i can successfully browse directly to the service with its base address from both mexhttps and mexhttp. Something is surely not right in either my we.config or ServiceReferences.ClientConfig file. – StackTrace Aug 05 '14 at 11:58
  • I got the problem, please give some name in the address of http and https enpoints something like below Now can you browse the service with below url baseaddress/EPWithoutSSL – Vinod Kumar Aug 05 '14 at 14:36
  • One major change is required, you should not have same base address to https and http endpoints because you will need to add the s to your protocol to your https endpoint but incase of http you should remove the s to your protocol. Please follow the above comment also to check whether your service is running under http endpoint or not – Vinod Kumar Aug 05 '14 at 14:42
  • can you post your complete service config file code, I can tell you where the mistake is – Vinod Kumar Aug 05 '14 at 14:43
  • i have trimmed down the config files and posted the xml code in this new qn http://stackoverflow.com/questions/25163113/how-to-support-calling-an-https-only-enabled-service-for-both-http-and-https-cal – StackTrace Aug 06 '14 at 14:46