我现在想了好几个小时才弄清楚这个问题。
我有一个在 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/