【问题标题】:WCF SSL endpoint address is not HTTPSWCF SSL 终结点地址不是 HTTPS
【发布时间】:2012-08-09 22:01:12
【问题描述】:

我试图在我的 PC (IIS 7) 上本地托管我的 SSL WCF 服务,但由于某种原因我无法连接到它。我需要的是在调用某些函数之前使用 SSL 并发送凭据来验证用户身份。

当我连接到它时,我得到 在 https://[计算机名称]/YYY.svc 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。

内部消息是远程服务器返回错误:(404) Not Found。

我注意到的是,当我访问 WSDL(通过 https 托管)时,端点地址不是 http*S*,我认为这就是我的服务可能失败的原因。

这是我的 WSDL 的一部分

<wsdl:service name="WSNAME">
<wsdl:port name="WSHttpBinding_INams" binding="tns:WSHttpBinding_INams">
 <soap12:address location="http://[computer name]/YYY.svc" /> 
  <wsa10:EndpointReference>
    <wsa10:Address>http://[computer name]/YYY.svc</wsa10:Address> 
     <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
       <Spn>host/[computername]</Spn> 
     </Identity>
 </wsa10:EndpointReference>

这是我的服务配置文件

 <service behaviorConfiguration="test" name="NewServiceType">
    <endpoint address="https://[computer name]/YYY.svc" binding="wsHttpBinding"
      bindingConfiguration="WsBinding" name="WS" contract="Authentication2.INams" />
    <endpoint address="mex" binding="mexHttpBinding" name="MX" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="https://[computer name]/XXX.svc" />
      </baseAddresses>
    </host>

谁能指出我做错了什么?

我的 web.config

   <system.serviceModel>
<protocolMapping>
  <remove scheme="http" />
  <add scheme="http" binding="wsHttpBinding" />
</protocolMapping>
<bindings>
  <wsHttpBinding>
    <binding name="wsbinding">
      <security mode="TransportWithMessageCredential">
        <transport proxyCredentialType="Basic" />
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<services>
  <service name="NewServiceType">
    <endpoint address="/WS" binding="wsHttpBinding"
      bindingConfiguration="wsbinding" name="WS" contract="Authentication3.IService1" />

    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
      name="MX" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"
        httpsGetUrl="https://[computerName]/Service1.svc" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />

【问题讨论】:

  • 你能发布定义“WsBinding”的配置吗?
  • 感谢您的回复.. 我刚刚发布了我的 web.config

标签: wcf ssl


【解决方案1】:

找到了!!

WCF service returns 404 over https but not http

问题是我的服务元素名称是编辑器默认添加的“MyNewService”或任何默认名称。您必须使用完全限定名称..

<services>
  <service name="[Namespace].[service class name]">

这花费了我 2 天的持续工作和研究。如果这对你有用,请投票让这些人回答 - 没有人提到过这一点..我不能因为我还是新人

【讨论】:

  • 哦,当然。抱歉,当我第一次设置服务时,我也遇到了这个问题,我一定是把它从我的记忆中抹去了,因为它太伤人了!很高兴你找到了答案
  • 创伤性...这是正确的使用词.. :D 非常感谢您的帮助!
  • 哇!从来没有想过这是我的问题。我缺少服务类名称(由于某种原因,我只有名称空间),但它在 http 上运行良好。切换到 ssl 时仅收到异常(以及 WSDL 中的错误端点)。谢谢!
【解决方案2】:

您的端点具有 WsBinding 定义的 bindingConfiguration 属性。 web.config 中应该有一个部分定义了这个配置,包括要使用的安全模式(如果你想使用 SSL,大概是 transport 或 transportWithMessageCredential)。

例如:

<bindings>
  <wsHttpBinding>
    <binding name="WsBinding">
       <security mode="Transport">
         <transport clientCredentialType="Windows" />
       </security>
    </binding>
  </wsHttpBinding>
</bindings>

此外,您还需要使用 443 上的绑定侦听配置 IIS,并引用适当命名的 SSL 证书。

对于凭证类型的窗口:

这对应于 IIS 中的集成 Windows 身份验证。设置时 到这个值,服务器也应该存在于 Windows 上 使用 Kerberos 协议作为其域控制器的域。 更多详情请关注MSDN WCF transport security page

您也可以使用 TransportWithMessageCredential。这使用 SSL 来加密连接,并且凭据在消息本身中传递(实际上是 SOAP 标头中的用户名和密码)。在这种情况下,您的绑定配置看起来更像:

       <security mode="TransportWithMessageCredential">
         <transport clientCredentialType="None" />
         <message clientCredentialType="Username" />
       </security>

然后您需要在服务上定义密码验证器行为以检查用户和密码。以下是有关此的更多信息:http://msdn.microsoft.com/en-us/library/aa354508.aspx

【讨论】:

  • 谢谢 - 但就是这样......刚刚用我的配置文件更新了我的帖子
  • 我注意到您正在使用 proxyCredentialType - 我以前没有使用过,但是您是否也尝试过设置 clientCredentialType?我更新后的帖子中的一些链接也可能有所帮助。
  • 感谢您的详细回复.. 我尝试按照您的建议更改模式并重新托管在 IIS 7 上,但是当我在 HTTPS 站点上的浏览器上检查 wsdl 时,我仍然得到这个
    **http**://[computername]/Service1.svc:Address> schemas.xmlsoap.org/ws/2006/02/addressingidentity"> 主机/[计算机名]
  • 我会看看我以前使用过的示例 web.config。不过,我认为我之前没有包含协议映射条目 - 你确定需要它吗?
猜你喜欢
  • 2012-09-25
  • 1970-01-01
  • 1970-01-01
  • 2019-03-09
  • 1970-01-01
  • 2017-06-27
  • 2011-04-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多