mscrm WebService开发 之 CrmDiscoveryService

代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrmDiscoveryWeservice.CrmSdk.Discovery;

namespace CrmDiscoveryWeservice
{
    
/// <summary>
    
/// author:seer lin
    
/// description:demo of using the CrmDiscoveryService to retrieve organization infomation
    
/// </summary>
    public partial class Form1 : Form
    {
        
public Form1()
        {
            InitializeComponent();
        }

        
private void button1_Click(object sender, EventArgs e)
        {
            CrmDiscoveryService discoveryService 
= new CrmDiscoveryService();
            discoveryService.UseDefaultCredentials 
= true;
            discoveryService.Url 
= "http://localhost:5555/MSCRMServices/2007/AD/CrmDiscoveryService.asmx";

            RetrieveOrganizationsRequest orgRequest 
= new RetrieveOrganizationsRequest();
            RetrieveOrganizationsResponse orgResponse 
= (RetrieveOrganizationsResponse)discoveryService.Execute(orgRequest);

            
foreach (OrganizationDetail orgDetail in orgResponse.OrganizationDetails)
            {
                MessageBox.Show(
"组织名称为:"+orgDetail.OrganizationName + "\nWebService访问地址:"+orgDetail.CrmServiceUrl);
            }
        }
    }
}
原文地址:https://www.cnblogs.com/seerlin/p/1756481.html