【问题标题】:Consuming a secure web service from WCF using supplied wsdl使用提供的 wsdl 从 WCF 使用安全 Web 服务
【发布时间】:2013-11-28 11:42:04
【问题描述】:

公司合作伙伴为我提供了一个 wsdl 和 xsd 文件,用于访问他们的 https 服务。 在soapUI 中配置安全性后,我已经安装了客户端证书并且可以使用SoapUI 访问他们的API。

在 .net 应用程序中使用 API 的后续步骤是什么?

我已经使用 svcutil 生成了代理。 我已将证书添加到本地计算机和当前用户 - 受信任的根证书颁发机构 证书来自服务提供商并通过soapUI 工作。它不是自签名的。

当我调用服务时,我得到无法为具有权限“WEB_SERVICE_URL:11851”的 SSL/TLS 建立安全通道。

我需要在配置文件中配置 https 还是我缺少什么?

谢谢

【问题讨论】:

  • 如果还没有,你的 URL 应该是 "https://WEB_SERVICE_URL:11851 ...另外,你应该在你的端口后面有一个类/方法,比如: https://WEB_SERVICE_URL: 11851/WebServiceName/Method 虽然 xsd 将帮助您制作要发送的 xml,但您应该从该公司获取一些示例数据并尝试一下。
  • 原来我必须在代码中指定证书

标签: wcf web-services wsdl wcf-security soap-client


【解决方案1】:

原来我必须在代码中指定证书

       // Create the binding.

        BasicHttpBinding customerBinding = new BasicHttpBinding();
        customerBinding.Security.Mode = BasicHttpSecurityMode.Transport;
        customerBinding.Security.Transport.ClientCredentialType =
           HttpClientCredentialType.Certificate;

        // Create the endpoint address. Note that the machine name 
        // must match the subject or DNS field of the X.509 certificate
        // used to authenticate the service. 
        EndpointAddress customerEa = new               
          EndpointAddress("https:URL_OF_SERVICE:11851/WebServices/GetCustomerDetailsService");

        // Create the client.             
        customerClient = new GetCustomerDetails1Client(customerBinding, customerEa);

        // The client must specify a certificate trusted by the server.
           customerClient.ClientCredentials.ClientCertificate.SetCertificate(
            StoreLocation.CurrentUser,
            StoreName.My,
            X509FindType.FindBySubjectName,
            "CERTIFICATE_NAME");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    相关资源
    最近更新 更多