WCF SOAP服务为HTTPS端点返回404 Not Found

时间:2016-01-05 10:48:44

标签: c# web-services wcf soap

我在域https://mydomain上的IIS 8.5中托管了.NET 4.5 WCF服务,并在IIS中配置了https绑定和自签名证书。

我可以在https://mydomain/FileService.svc

上的浏览器中访问我服务的配置页面

当我尝试使用SoapUI将POST某些数据发送到服务端点https://mydomain/FileService.svc/receiveRequest时,我会回来HTTP/1.1 404 Not Found

我的web.config服务配置如下所示:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <!-- maxReceivedMessageSize = 1073741824 = 1 GB -->
      <binding maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" >
        <security mode="None"></security>
      </binding>
    </basicHttpBinding>
  </bindings>

  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>

  <protocolMapping>
    <add binding="basicHttpBinding" scheme="http" />
  </protocolMapping>

  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  <services>

    <service name="Foo.FileService">
      <endpoint contract="IFileService" binding="basicHttpBinding"></endpoint>
    </service>
  </services>
</system.serviceModel>

知道如何解决这个问题或获取更多信息以便进一步调试? 感谢。

编辑1

我已在 dev 计算机上测试了该服务。它部署在http://localhost上,SoapUI的调用工作正常。我使用http://localhost/FileService.svc/receiveRequest来调用服务端点,它使用200和SOAP消息进行响应。

编辑2

在没有http://mydomain/FileService.svc/receiveRequest测试计算机上访问WCF服务端点HTTPS时,它可以正常工作。

1 个答案:

答案 0 :(得分:3)

终于破解了!我错过了HTTPS端点的绑定,其中security模式无法设置为None

这是绑定的更新配置:

<basicHttpBinding>
  <binding name="myHttpsBinding" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" maxBufferPoolSize="1073741824">
    <security mode="Transport">
      <transport clientCredentialType="None"/>
    </security>
  </binding>

  <binding name="myHttpBinding" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" maxBufferPoolSize="1073741824">
    <security mode="None" />
  </binding>    
</basicHttpBinding>

这是服务端点的更新配置:

<service name="Foo.FileService">
  <!-- HTTPS Endpoint -->
  <endpoint contract="IFileService" binding="basicHttpBinding" bindingConfiguration="myHttpsBinding" ></endpoint>
  <!-- HTTP Endpoint -->
  <endpoint contract="IFileService" binding="basicHttpBinding" bindingConfiguration="myHttpBinding" ></endpoint>
</service>

现在两个端点http://mydomain/FileService.svc/receiveRequesthttps://mydomain/FileService.svc/receiveRequest都适用于我。