我已经好几个小时了解这个问题。
我有一个我在II7上托管的wcf服务,当我使用普通的http协议时,一切正常。
我添加了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
这就是我得到的
https://serverName.domname.local/WCFTest/MyWebService.svc没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。
任何人都可以帮我这个吗?我真的不明白发生了什么......
注意:我可以使用Internet Explorer正确访问Web服务(所以我猜我的证书没问题)
答案 0 :(得分:4)
我认为服务器web.config可能是错误的。我在客户端使用以下app.config获得了WCF over SSL工作。
<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>
唯一可见的区别是我已设置为Windows的ClientCredentialType,因为我想使用集成的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添加到问题中。
答案 1 :(得分:3)
你是对的,
服务器端的Sg错误。
这是我如何运作
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport">
<transport clientCredentialType ="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="App_WcfWebService.AppWebServiceBehavior" name="App_WcfWebService.AppWebService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration ="wsHttpEndpointBinding" contract="App_WcfWebService.IAppWebService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="App_WcfWebService.AppWebServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentSessions="90" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>