简体   繁体   English

WCF SSL端点地址不是HTTPS

[英]WCF SSL endpoint address is not HTTPS

Im trying to host my SSL WCF service locally on my PC (IIS 7) and for some reason i cant connect to it. 我试图在我的PC(IIS 7)本地托管我的SSL WCF服务,由于某种原因我无法连接到它。 What i need is to use SSL and send in credntials to authenticate the user before calling some function. 我需要的是在调用某个函数之前使用SSL并发送信用证来验证用户。

When i connect to it, i get There was no endpoint listening at https://[computer name]/YYY.svc that could accept the message. 当我连接到它时,我得到了没有端点监听https:// [计算机名称] /YYY.svc可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由错误的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参阅InnerException(如果存在)。

the inner message is The remote server returned an error: (404) Not Found. 内部消息是远程服务器返回错误:(404)Not Found。

What i have noticed is that when i access the WSDL (hosted over https) the endpoint address is not http* S * and i think that is why my service is probably failing. 我注意到的是,当我访问WSDL(通过https托管)时,端点地址不是http * S *,我认为这就是我的服务可能失败的原因。

here is part of my WSDL 这是我的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>

This is my service config file 这是我的服务配置文件

 <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>

can anyone point out what am i doing wrong? 任何人都可以指出我做错了什么?

my web.config 我的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" />

FOUND IT !! 找到了 !!

WCF service returns 404 over https but not http WCF服务通过https而不是http返回404

the problem is that my service element name was what the editor adds by default "MyNewService" or whatever the default name is. 问题是我的服务元素名称是编辑器默认添加的“MyNewService”或默认名称。 You HAVE to use the fully qualified name.. 您必须使用完全限定名称..

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

This cost me over 2 long days of constant work and research. 这花费了我超过2天的不断工作和研究。 If this works for you, please vote that guys answer up - NO ONE has ever mentioned this point .. i couldnt because im still new 如果这适合你,请投票给那些家伙回答 - 没有人提到这一点..我不能因为我还是新的

Your endpoint has a bindingConfiguration attribute defined of WsBinding. 您的端点具有由WsBinding定义的bindingConfiguration属性。 There should be a section of the web.config that defines this configuration, including the security mode to be used (presumably transport or transportWithMessageCredential if you want to use SSL). 应该有web.config的一部分定义此配置,包括要使用的安全模式(如果您想使用SSL,可能是transport或transportWithMessageCredential)。

For example: 例如:

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

Additionally you'll need to configure IIS with a binding listening on 443, referencing an appropriately named SSL certificate. 此外,您需要使用绑定侦听443配置IIS,并引用适当命名的SSL证书。

For a credential type of windows: 对于凭证类型的窗口:

This corresponds to integrated Windows authentication in IIS. 这对应于IIS中的集成Windows身份验证。 When set to this value, the server is also expected to exist on a Windows domain that uses the Kerberos protocol as its domain controller. 设置为此值时,服务器也应存在于使用Kerberos协议作为其域控制器的Windows域上。 More details on this on the MSDN WCF transport security page 有关MSDN WCF传输安全页面上的更多详细信息

Alternatively you can use TransportWithMessageCredential. 或者,您可以使用TransportWithMessageCredential。 This uses SSL to encrypt the connection, and the credentials are passed in the message itself (effectively username and password in the SOAP header). 这使用SSL来加密连接,凭证在消息本身中传递(实际上是SOAP头中的用户名和密码)。 In that case your binding configuration looks more like: 在这种情况下,您的绑定配置看起来更像:

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

You then need to define a password validator behavior on the service to check the user and password. 然后,您需要在服务上定义密码验证程序行为以检查用户和密码。 Here's some more info on that: http://msdn.microsoft.com/en-us/library/aa354508.aspx 这里有一些更多的信息: http//msdn.microsoft.com/en-us/library/aa354508.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM