WCF + SSL未找到终结点。

12

我已经为了解决这个问题奋斗了几个小时。

我有一个托管在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正确访问WebService(所以我想我的证书没问题)。


可能查看服务器配置会有帮助。 - Dmitry Ornatsky
2个回答

4

我认为这里可能是服务器的web.config有问题。在客户端上,我使用以下的app.config使WCF通过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>

唯一的可见差异是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文件添加到问题中。


3

你对此的看法是正确的,

服务器端出现了问题。

这是我解决它的方法。

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接