【问题标题】:Web Service (Discovery.svc?wsdl) and Forefront TMG authenticationWeb 服务 (Discovery.svc?wsdl) 和 Forefront TMG 身份验证
【发布时间】:2013-06-06 07:20:43
【问题描述】:

我有一个 WCF 服务 URL,例如 https://crm.xxxx.com/XRMServices/2011/Discovery.svc?wsdl。但是如果我在浏览器窗口中打开这个 URL,我会得到一个授权屏幕:

如果我尝试在我的 C# 代码中添加此 URL,则会遇到异常:

ServiceConfigurationFactory.CreateManagement<T>(new Uri(url));

例外:元数据包含无法解析的引用:“https://crm.xxxx.com/XRMServices/2011/Discovery.svc?wsdl”。

例外:元数据包含无法解析的引用:“https://crm.xxxx.com/XRMServices/2011/Organisation.svc?wsdl”。

如果我有用户登录名和密码,如何从我的客户端应用程序访问 Web 服务?

【问题讨论】:

    标签: c# wcf web-services authentication


    【解决方案1】:

    TMG 基本上是一个公司防火墙,它会阻止您的传入请求,因此您首先必须与 TMG 协商,然后将您的请求发送到您的 WCF 服务。

    这是我从the following MSDN blog entry 获取的一个示例绑定,用于处理类似问题:

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1">
                    <security mode="Transport">
                        <transport clientCredentialType="Certificate" />
                       </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://www.myservice.com/Service1.svc"
                      behaviorConfiguration="myEndpointBehaviour"
                      binding="basicHttpBinding"
                      bindingConfiguration="BasicHttpBinding_IService1"
                      contract="Client.IService1"
                      name="BasicHttpBinding_IService1" />
        </client>
        <behaviors>
            <endpointBehaviors>
                <behavior name="myEndpointBehaviour">
                    <clientCredentials>
                        <clientCertificate
                            storeName="My" 
                            storeLocation="CurrentUser"
                            findValue="CN=WCF client cert 2" />
                    </clientCredentials>
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>
    

    如果您的服务没有启用任何消息级安全性,则此绑定已经完成。

    顺便说一句,请确保您拥有正确的证书以访问该服务,登录名和密码可能意味着消息级别的安全性。

    【讨论】:

      猜你喜欢
      • 2016-06-10
      • 1970-01-01
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      • 2014-01-03
      • 1970-01-01
      • 2013-06-22
      • 2020-11-13
      相关资源
      最近更新 更多