Posting this in case it helps someone:

I was using OrganizationServiceClient to use the SOAP endpoint in CRM 2011.

( Note:

1. No Xrm.Sdk or CRM.Sdk dlls included in solution.

2. No Reference.cs generated through svcUtil.exe either

)

Because of dlls not included in solution, WhoAmIRequest and WhoAmIResponse classes are not available by default.

OrganizationRequest need to look for WhoAmIRequest.

OrganizationServiceClient _orgProxy = GetProxy(System.Net.CredentialCache.DefaultNetworkCredentials);
OrganizationRequest req = new OrganizationRequest() { RequestName = “WhoAmIRequest” };
OrganizationResponse res = new OrganizationResponse() { ResponseName = “WhoAmIResponse” };
res = _orgProxy.Execute(req);

While debugging, I came across this error:

“Request not supported: WhoAmIRequest”

Drilled down further, for the source of WhoAmIRequest, I found this class is member of Microsoft.Crm.Sdk namespace (along with WhoAmIResponse).

http://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.aspx

But as I have no sdk.dlls in my solution added, and just a service reference, I tried to look for List of Requests which OrganizationRequest supports:

http://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.organizationrequest.requestname.aspx

And i found that it is “WhoAmI”

Hence, to make a WhoAmIRequest similar to CRM you need to use following :

OrganizationServiceClient _orgProxy = GetProxy(System.Net.CredentialCache.DefaultNetworkCredentials);
OrganizationRequest req = new OrganizationRequest() { RequestName = “WhoAmI” };
OrganizationResponse res = new OrganizationResponse() { ResponseName = “WhoAmI” };
res = _orgProxy.Execute(req);

Hope this helps 🙂

Advertisements

2 thoughts on “CRM 2011: WhoAmIRequest with pure WCF call/OrganizationServiceClient

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s