0

I tried updating the App.config files for the client and service for the MS sample applications in WF_WCF_Samples\WCF\Basic\Services\Hosting\WindowsService\CS\WindowsService.sln so that secure bindings were used but when the client makes the call to the service method an exception is thrown

"An error occurred while making the HTTP request to https:// .... /servicemodelsamples/service. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server."

Inner exception "The underlying connection was closed: An unexpected error occurred on a send"

As far as I can see both the server and client configs match and use Transport security mode and the mex endpoint now uses mexHttpsBinding rather than mexHttpBinding with the service behaviour appropriately enabled.

Can someone tell me what is missing or incorrect as I have tried numerous tweaks with no success?

Thanks

The server and client configs are

    <?xml version="1.0"?>
<!--Copyright (c) Microsoft Corporation.  All Rights Reserved.-->
<configuration>

  <system.serviceModel>

    <services>
      <service name="Microsoft.Samples.WindowsService.WcfCalculatorService">
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:8000/ServiceModelSamples/service"/>
          </baseAddresses>
        </host>
        <!-- This endpoint is exposed at the base address provided by host: https://localhost:8000/ServiceModelSamples/service -->
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="https" contract="Microsoft.Samples.WindowsService.ICalculator"/>
        <!-- The mex endpoint is exposed at https://localhost:8000/ServiceModelSamples/service/mex -->
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <!-- Configure BasicHttp binding with Transport security mode and clientCredentialType as None -->
        <binding name="https">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <!-- For debugging purposes set the includeExceptionDetailInFaults attribute to true -->
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>
</configuration>

and

    <?xml version="1.0"?>
<!--Copyright (c) Microsoft Corporation.  All Rights Reserved.-->
<configuration>
  <system.serviceModel>

    <client>
      <endpoint name="" address="https://localhost:8000/servicemodelsamples/service" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="Microsoft.Samples.WindowsService.ICalculator"/>
    </client>

    <bindings>
      <basicHttpBinding>
        <!-- Configure BasicHttp binding with Transport security mode and clientCredentialType as None -->
        <binding name="Binding1">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

  </system.serviceModel>

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
4

1 回答 1

0

mex cant be https

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>

change to

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

于 2012-08-09T09:01:23.307 回答