Intentando crear leads en CRM dinámico usando API en PHP

Estoy tratando de crear clientes potenciales en CRM dinámico usando API en PHP pero obtengo un error de 400 html. Mi CRM dinámico utiliza la autenticación de Active Directory. Puedo obtener con éxito la lista de clientes potenciales utilizando la API pero no puedo crear una. Aquí está mi código:

$xml = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
    <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <entity xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
        <a:Attributes xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
          <a:KeyValuePairOfstringanyType>
            <b:key>Firstname/b:key>
            <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">TestTopic</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>Lastname</b:key>
            <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">testName</b:value>
          </a:KeyValuePairOfstringanyType>
        </a:Attributes>
        <a:EntityState i:nil="true" />
        <a:FormattedValues xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
        <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
        <a:LogicalName>lead</a:LogicalName>
        <a:RelatedEntities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      </entity>
    </Create>
  </s:Body></s:Envelope>';

$headers = array ( 
                    "POST " . "/Organization.svc" . " HTTP/1.1",
                    "Host: " . $host,
                    "Connection: Keep-Alive",
                    "Content-type: application/SOAP+xml; charset=UTF-8"
                    //,"Content-length: " . strlen ( $xml )
            );

$ch = curl_init ();
            curl_setopt ( $ch, CURLOPT_URL, $crm_url  . "/XRMServices/2011/Organization.svc" );
        //curl_setopt($ch, CURLOPT_HTTPHEADER, array('"POST " . "/Organization.svc" . " HTTP/1.1","Host: " . $host,"Connection: Keep-Alive","Content-type: application/json; charset=UTF-8"'));
            curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
            curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST");
            curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
            curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
            curl_setopt ( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
            curl_setopt ( $ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
            curl_setopt ( $ch, CURLOPT_USERPWD, "$username:$password");
            curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
            curl_setopt ( $ch, CURLOPT_POST, 1 );
            curl_setopt ( $ch, CURLOPT_POSTFIELDS, $xml );

            $response = curl_exec($ch);
            if( $response === false) { echo 'Curl error: ' . curl_error($ch);}
            $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );echo "Status: $status ";
            $response=json_decode($response, true);
            print_r($response);
            curl_close($ch);

Respuestas a la pregunta(1)

Su respuesta a la pregunta