0

我曾经连接到这个测试应用程序,一周后我回来了,现在出现了身份验证问题。在下面获取System.InvalidOperationException详细信息

(Exception e) {
e.Message = "Metadata contains a reference that cannot be resolved: 'https://ORGNAME.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl'."

e.InnerException = "The remote server returned an error: (407) Proxy Authentication Required."
e.InnerException.InnerException = "The logon attempt failed."

}

因为我在域上并且需要代理才能看到Organization.svc我在 App.config 中有以下内容来满足这一点:

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy bypassonlocal="True" proxyaddress="http://PROXYURI:8080"   />
  </defaultProxy>
</system.net>
<connectionStrings>
  <!-- using online -->
  <add name="Server=CRM Online, organization=contoso,user=someone" connectionString="Url=https://contoso.crm.dynamics.com;Username=someone@contoso.onmicrosoft.com; Password=password;"/>
</connectionStrings>

我可以使用浏览器浏览到 Organization.svc?wsdl。但不在代码 c# 中:

// Establish a connection to the organization web service (using the above connection string).
var connection = CrmConnection.Parse(ConfigurationManager.ConnectionStrings[1].ConnectionString);

using (_orgService = new OrganizationService(connection))
{
...

    var context = new OrganizationServiceContext(_orgService);
    //than as soon as I use _orgService I get the Exception 
    List<Contact> firstNameContacts = (from c in context.CreateQuery<Contact>()
                            where c.FirstName == "Shane"
                            select c).ToList();


  ...
}

就像我说的那样,自从我上次使用它连接到在线 MSCRM 2015 服务以来,什么都没有改变,但是对于域上的密码重置(请参阅我的评论,确认这是问题,旧密码似乎仅在使用代码创建服务调用时才被兑现)。

 `Edit`

进一步调查表明,当我运行“PluginregistrationTool”时,它似乎是环境问题,在跟踪下方,确认了我在代码中遇到的异常(但是为什么?)

Inner Exception<b> Level 1:</b> 
    Source  : System
    Method  : GetResponse
    Error   : `The remote server returned an error: (407) Proxy Authentication Required.`
    Stack Trace : at System.Net.HttpWebRequest.GetResponse()
    ...
    Source  : System.serviceModel
    Method  : Retrieve
    Error   : Metadata contains a reference that cannot be resolved: 'https://dev.crm4.dynamics.com/XRMServices/2011/Discovery.svc?wsdl'.
    ...
    Inner Exception <b>Level 1</b>:
    Source  : System
    Method  : GetResponse
    Error   : `The remote server returned an error: (407) Proxy Authentication Required.`
    Stack Trace : at System.Net.HttpWebRequest.GetResponse()
    ...
    Inner Exception <b>Level 2</b>  :
    Source  : System
    Error   : `The logon attempt failed`
    Stack Trace : at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode)
    ...
4

1 回答 1

0

代理保留来自 Active Directory 的用户名和密码,应该刷新,做开发应该使用网络帐户 *不会过期并且不会在任何时间段内更改密码的帐户。

于 2015-04-30T12:30:01.723 回答