use of com.microsoft.schemas.xrm._2011.contracts.discovery.RetrieveOrganizationRequest in project tdi-studio-se by Talend.
the class MSCRMClient method discoverOrganizationUrl.
private static String discoverOrganizationUrl(DiscoveryServiceStub serviceStub, String organizationUniqueName) throws RemoteException, IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage {
try {
RetrieveOrganizationRequest request = RetrieveOrganizationRequest.Factory.newInstance();
request.setUniqueName(organizationUniqueName);
Execute exe = Execute.Factory.newInstance();
exe.setRequest(request);
ExecuteDocument exeDoc = ExecuteDocument.Factory.newInstance();
exeDoc.setExecute(exe);
ExecuteResponseDocument executeRespDoc = serviceStub.execute(exeDoc);
ExecuteResponse executeResp = executeRespDoc.getExecuteResponse();
RetrieveOrganizationResponse result = (RetrieveOrganizationResponse) executeResp.getExecuteResult();
OrganizationDetail orgDetail = result.getDetail();
KeyValuePairOfEndpointTypestringztYlk6OT[] keyValuePairs = orgDetail.getEndpoints().getKeyValuePairOfEndpointTypestringztYlk6OTArray();
for (KeyValuePairOfEndpointTypestringztYlk6OT keyValuePair : keyValuePairs) {
if (keyValuePair.getKey() == EndpointType.ORGANIZATION_SERVICE) {
return keyValuePair.getValue();
}
}
} catch (RemoteException e) {
logger.error(e.getMessage());
throw e;
} catch (IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage e) {
logger.error(e.getMessage());
throw e;
}
return null;
}
Aggregations