Search code examples
phpsoapdynamics-crmdynamics-crm-2015dynamics-crm-2016

Issue getting identifier from XRMServices/2011/Organization.svc


I have some code similar to Jason Lattimer's below that used to work however now fails. I can find the "Identifier" in the wsdl anymore. Can anyone provide assistance on this?

function GetADFS($url) {
    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, $url . "XrmServices/2011/Organization.svc?wsdl=wsdl0" );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );

    $response = curl_exec ( $ch );
    curl_close ( $ch );

    $responsedom = new DomDocument ();
    $responsedom->loadXML ( $response );

    // **************************************************       
    // **************************************************
    // Can no longer find this Identifier
    // **************************************************
    // **************************************************
    $identifiers = $responsedom->getElementsbyTagName ( "Identifier" );
    $identifier = $identifiers->item ( 0 )->textContent;

    return str_replace ( "http://", "https://", $identifier );
}

Solution

  • It's in namespace 'ms-xrm' so replace

    $identifiers = $responsedom->getElementsbyTagName ( "Identifier" );
    

    with

    $identifiers = $responsedom->getElementsbyTagNameNS ( "ms-xrm","Identifier" );
    

    and check. Next thing is to check in actual WSDL if you see this node if not then there may be a problem with configuration of your CRM because that node is only available when you are using ADFS.