【问题标题】:Client App with WsHttpBinding gets "no endpoint listening at..."带有 WsHttpBinding 的客户端应用程序获得“没有端点正在监听...”
【发布时间】:2016-07-25 15:11:48
【问题描述】:

我有一个客户端应用程序,它与托管在服务器(我们将其称为 hostServer)上的 Web 服务进行通信。我的客户端应用程序可以使用 basicHttpBinding 构建和连接。但是,出于安全原因,我试图暗示 wsHttpBinding

上周午餐前,我可以发誓它使用的是硬编码证书。吃完午饭回来,检查了我的代码,现在它不会运行了。我不断收到“https://hostServer:1234/Service.svc/MyServiceName 上没有可以接受消息的端点监听。这通常是由不正确的地址或 SOAP 操作引起的。”。我尝试重新检查我的设置,重新跟踪我的步骤,但似乎无法恢复到我所处的正常运行状态。

我正在使用地址为“https://hostServer:1234/Service.svc?singleWsdl”的 ServiceReference。我可以毫无问题地导航到“https://hostServer:1234/Service.svc”并查看 Wsdl。

我的客户代码是

WSHttpBinding wsBinding = new WSHttpBinding(SecurityMode.Transport);
wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

Client = new MyServiceName(wsBinding, new EndpointAddress(endpoint));

Client.ClientCredentials.ClientCertificate.SetCertificate(
  StoreLocation.CurrentUser,
  StoreName.My,
  X509FindType.FindBySubjectName,
  "localCertName");

 Client.ChangePassword("test_user", "pt", "a1");

我的价值端点 = https://hostServer:1234/Service.svc/MyServiceName

我的 IIS 站点设置了 Http 和 Https 绑定(具有正确的 IP 和端口 ID)

我真的需要在起飞前让这段代码正常工作(我妻子随时都会带着我们的第二个孩子)。我已经调试了 2 天了,除了我花了一些时间让它保持原样。请帮忙。

【问题讨论】:

    标签: web-services https wshttpbinding


    【解决方案1】:

    所以我终于能够再次让它工作。列出下面执行的步骤,希望对其他人有所帮助。

    在 IIS 服务器上(IIS 管理器)

    修改“站点绑定”以包括 HTTP 和 HTTPS(w/不同的端口号)

    将 SSL 设置设置为“需要 SSL”和“接受”

    在 IIS 服务器 (Web.Config) 上:

    添加

    <bindings> 
      <wsHttpBinding> 
        <binding name="wsHttpEndpointBinding"> 
          <security mode="Transport"> 
            <transport clientCredentialType ="Certificate"/> 
          </security> 
        </binding> 
      </wsHttpBinding> 
    </bindings>
    

    到“System.ServiceModel”标签。

    另外,将 'bindingConfiguration="wsHttpEndpointBinding"' 添加到我的端点。

    在代码中

    更新了端点地址以使用在 IIS 服务器上生成的地址。

    使用以下代码创建端点

     WSHttpBinding wsBinding = new WSHttpBinding(SecurityMode.Transport); 
        wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; 
        Client = new ServiceClient(wsBinding, new EndpointAddress(endpoint)); 
        Client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMac‌​hine, StoreName.My, X509FindType.FindByIssuerName, certName);
    

    【讨论】:

      猜你喜欢
      • 2019-12-14
      • 2015-10-17
      • 1970-01-01
      • 2014-12-05
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      相关资源
      最近更新 更多