WCF + SSL 未找到端点

标签 wcf web-services ssl

我现在想了好几个小时才弄清楚这个问题。

我有一个在 II7 上托管的 wcf 服务,当我使用普通的 http 协议(protocol)时一切正常。

我添加了 SSL 功能,从那以后我无法从代码访问它。我可以创建一个客户端,但不能运行它的任何方法。

这是我的

 <system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttp0">
                <security mode="Transport">
                    <transport realm ="" clientCredentialType="None" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://serverName.domname.local/WCFTest/MyWebServicec.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttp0" contract="SSLWebService.IMyWebService"
            name="WSEP">
            <identity>
                <dns value="serverName.domname.local" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我向我的项目添加了服务引用

我就是这样用的

Dim client As MyWebServiceClient = New MyWebServiceClient()
Try
    client.GetDocumentByDocID(5)
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

这是我得到的

There was no endpoint listening at https://serverName.domname.local/WCFTest/MyWebService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

谁能帮我解决这个问题?我真的不明白这是怎么回事...

注意:我可以使用 Internet Explorer 正确访问 web 服务(所以我想我的证书没问题)

最佳答案

我认为服务器 web.config 可能是这里的错误。我在客户端通过 SSL 使用以下 app.config 获得了 WCF。

<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IService" >
          <security mode="Transport">
            <transport realm ="" clientCredentialType="Windows" />
          </security>
        </binding>

      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://mycomputer/Service/Service.svc"
          binding="wsHttpBinding"
          bindingConfiguration="WSHttpBinding_IService"
          contract="ServiceProxy.IService" name="WSHttpBinding_IService">
        <identity>
          <dns value="mycomputer" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

唯一可见的区别是 ClientCredentialType,我已将其设置为 Windows,因为我想使用集成的 Windows 身份验证。服务器 web.config 包含以下行来设置客户端可以使用的服务。

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WindowsBinding">
          <security mode="Transport">
            <transport proxyCredentialType="Windows" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="Service.Service1Behavior"
               name="Service.Service">
        <endpoint address="" binding="wsHttpBinding"
                  bindingConfiguration="WindowsBinding"
                  contract="ServiceInterface.IService">
          <identity>
            <dns value="mycomputer" />
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Service.Service1Behavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

您能否将其与服务器端的 web.config 进行比较,看看有何不同?或者将您的 web.config 添加到问题中。

关于WCF + SSL 未找到端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/797903/

相关文章:

.net - 保护 WCF 服务的最佳方式是什么?

java - 在java中压缩base 64 png图像

macos - Web 请求如何发出并且不被像 Charles 这样的数据包嗅探器工具检测到?

c# WCF最大字符串内容长度配额

.net - 将 protobuf-net 添加到我的 WCF Rest 服务

c# - 让 POST 端点在自托管 (WebServiceHost) C# web 服务中工作?

java - 支持 "PATCH"动词 - WSHttpHandler handleExchange 给出警告 : Cannot handle HTTP method: PATCH

python-2.7 - 如何在 python 2.7 中使用 ssl

apache - nginx 代理到具有自证书的上游 apache 服务器

c# - 使用 WCF OperationContext 通过 Channel 传递 header 值