I was basing my code on the wsdlbasedproxies example in the CRM 2011 SDK. Once you find it, this code is reasonably well documented.
However, when testing it, I could connect to the IDiscoveryService without problems, but continually got the error 'An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail' when connecting to the IOrganizationService.
Ultimately the issue was with the AppliesTo constant. The setup.txt instructions tell you to set this based on data in the
After more time than I'd like, I found out that the IOrganizationService in EMEA works when AppliesTo = "urn:crm4:dynamics.com". My guess is that "urn:crm5:dynamics.com" would be correct in Asia (if anybody has a sample login to try, let me know and I'll confirm it one way or another).
So, this needed a few minor code changes to the code in Online\program.cs, as you need different tokens for each service. For EMEA, I used the following:
private const string AppliesToDiscovery = "urn:crmemea:dynamics.com";
private const string AppliesTo = "urn:crm4:dynamics.com";
static void Main(string[] args)
{
//Authenticate the user
SecurityToken tokenDiscovery = Authenticate(UserName, UserPassword, AppliesToDiscovery, Policy, IssuerUri);
SecurityToken token = Authenticate(UserName, UserPassword, AppliesTo, Policy, IssuerUri);
//Execute the sample
string serviceUrl = DiscoverOrganizationUrl(tokenDiscovery, OrganizationUniqueName, DiscoveryServiceUrl);
ExecuteWhoAmI(token, serviceUrl);
}
1 comments:
even for NA instance, you have to use different AppliesTo: urn:crm:dynamics.com" for Org, and urn:crmna:dynamics.com for Discovery.
Strange/weird design!?
Post a Comment