c# - 如何消费https wcf服务?

标签 c# web-services wcf ssl soap

我需要使用一个 https wcf 服务。它的网址如下:https://www.abxyz.com:8082/MasterPassPspUi/PspUiService.svc

我已经创建了一个项目并配置了 web.config,如下所示:

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IPspUiService"
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="https://www.abxyz.com:8082/MasterPassPspUi/PspUiService.svc"
            binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IPspUiService"
            contract="PspUiService.IPspUiService" 
            behaviorConfiguration="SoapInspector" 
            name="BasicHttpBinding_IPspUiService" />
</client>

当我调用它返回的服务时

There was no endpoint listening at https://www.abxyz.com:8082/MasterPassPspUi/PspUiService.svc that could accept the message. This is often caused by an incorrect address or SOAP action.

当我将 url 更改为 dns 地址时:

https:/212.2.245.34:8082/MasterPassPspUi/PspUiService.svc

Could not establish trust relationship for the SSL/TLS secure channel with authority '212.2.245.34:8082'

实际上我可以使用网络浏览器访问该服务,但是您能帮我看看如何通过 https 使用此 wcf 服务吗?

最佳答案

第一个错误看起来你无法连接服务,名称。能不能打开地址https://www.abxyz.com:8082/MasterPassPspUi/PspUiService.svc在你的浏览器?如果打不开但是可以打开https://212.2.245.34:8082/MasterPassPspUi/PspUiService.svc地址,那么我认为是系统配置的问题。是正确的域名吗?

由于第二个错误,你进入了服务器,但是你得到了一个安全错误。您的 IIS 中是否有有效的证书? - 如果 IIS 和客户端在同一台服务器上,您可以使用无效证书调用 Web 服务。 -

关于c# - 如何消费https wcf服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32246836/

相关文章:

C# 计时器在一定数量的滴答后自动停止

c# - 如何指定 .NET 泛型约束中不允许的类型?

c# - 如何调用从 web 服务返回数组的函数?

wcf - 通过 WCF 服务的 JSON 输出中的 URL 格式不正确

c# - 将两个实体之间的关系保存为 N-N 关联

.net - 使用 .NET 3.5 创建什么? Web 服务或 Windows 服务

c# - protobuf-csharp-端口

c# - 为什么使用NEST使用自定义分析器排序的嵌套ElasticSearch返回无效结果?

java - 无法在 jboss 5.0.1 中创建代理

java - cxf-rt-frontend-jaxws 的 Maven 依赖项破坏了现有的 SOAP 客户端