Monday, August 1, 2011

Get Information About a Specific Organization Using .NET in Microsoft Dynamics CRM 2011

This illustration shows how to get information about a specific organization using .NET in Microsoft Dynamics CRM 2011 utilizing .NET  with the RetrieveOrganizationRequest and the discovery serivice.

Ok, here is what the code looks like!

RetrieveOrganizationRequest req = new RetrieveOrganizationRequest();
req.UniqueName = "crmNAorgf3740";
RetrieveOrganizationResponse resp = (RetrieveOrganizationResponse)slds.Execute(req);

Below is what the returned envelope looks like.  You can see the different properties that will be returned in the response.

For information on how to log SOAP messages against the discovery service, check out this post:
http://mileyja.blogspot.com/2011/07/soap-message-logging-against-discovery.html

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <ExecuteResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <ExecuteResult i:type="a:RetrieveOrganizationResponse" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts/Discovery">
        <a:Detail>
          <a:Endpoints xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
            <a:KeyValuePairOfEndpointTypestringztYlk6OT>
              <b:key>WebApplication</b:key>
              <b:value>https://sogetiusa.crm.dynamics.com/</b:value>
            </a:KeyValuePairOfEndpointTypestringztYlk6OT>
            <a:KeyValuePairOfEndpointTypestringztYlk6OT>
              <b:key>OrganizationService</b:key>
              <b:value>https://sogetiusa.api.crm.dynamics.com/XRMServices/2011/Organization.svc</b:value>
            </a:KeyValuePairOfEndpointTypestringztYlk6OT>
            <a:KeyValuePairOfEndpointTypestringztYlk6OT>
              <b:key>OrganizationDataService</b:key>
              <b:value>https://sogetiusa.api.crm.dynamics.com/XRMServices/2011/OrganizationData.svc</b:value>
            </a:KeyValuePairOfEndpointTypestringztYlk6OT>
          </a:Endpoints>
          <a:FriendlyName>Sogeti USA</a:FriendlyName>
          <a:OrganizationId>f3740acf-9f06-4645-9661-8e521b236451</a:OrganizationId>
          <a:OrganizationVersion>5.0.9688.1244</a:OrganizationVersion>
          <a:State>Enabled</a:State>
          <a:UniqueName>crmNAorgf3740</a:UniqueName>
          <a:UrlName>sogetiusa</a:UrlName>
        </a:Detail>
      </ExecuteResult>
    </ExecuteResponse>
  </s:Body>
</s:Envelope>

I hope this helps!

No comments:

Post a Comment