从php到CRMOnline的SOAP请求

从php到CRMOnline的SOAP请求,php,soap,dynamics-crm-2011,Php,Soap,Dynamics Crm 2011,我有一个简单的PHP脚本,其中包含对CRM Online的SOAP调用。我可以创建和检索记录,但在设置实体的客户时遇到了问题。我的一个SOAP调用就是这样的;它创建记录,但不设置客户 $liveIDManager = new LiveIDManager(); $securityData = $liveIDManager->authenticateWithLiveID($organizationServiceURL, $liveIDUseranme, $liveID

我有一个简单的PHP脚本,其中包含对CRM Online的SOAP调用。我可以创建和检索记录,但在设置实体的客户时遇到了问题。我的一个SOAP调用就是这样的;它创建记录,但不设置客户

        $liveIDManager = new LiveIDManager();

    $securityData = $liveIDManager->authenticateWithLiveID($organizationServiceURL, $liveIDUseranme, $liveIDPassword);

    if($securityData!=null && isset($securityData)){
        //echo ("\nKey Identifier:" . $securityData->getKeyIdentifier());
        //echo ("\nSecurity Token 1:" . $securityData->getSecurityToken0());
        //echo ("\nSecurity Token 2:" . $securityData->getSecurityToken1());
    }else{
        echo "Unable to authenticate LiveId.";
        return;
    }
    echo "\n";
            $domainname = substr($CRMURL,8,-1);
    $pos = strpos($domainname, "/");
    $domainname = substr($domainname,0,$pos);
    print_r($data);
    $contactRequest = EntityUtils::getCreateCRMSoapHeader($CRMURL, $securityData).
    <s:Body>
                <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
                <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                    <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                        <b:KeyValuePairOfstringanyType>
                            <c:key>firstname</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">'.$data['Account']['name'].'</c:value>
                            <c:key>parentcustomerid</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">'.$data['Account']['id'].'</c:value>
                        </b:KeyValuePairOfstringanyType>
                    </b:Attributes>
                    <b:EntityState i:nil="true"/>
                    <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                    <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
                    <b:LogicalName>contact</b:LogicalName>
                    <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                </entity>
                </Create>
            </s:Body>
    $response =  LiveIDManager::GetSOAPResponse("/Organization.svc", $domainname, $CRMURL, $accountsRequest);
    echo $response;
    $createResult ="";
    if($response!=null && $response!=""){
        preg_match('/<CreateResult>(.*)<\/CreateResult>/', $response, $matches);

        $createResult =  $matches[1];
    }
$liveIDManager=new liveIDManager();
$securityData=$liveIDManager->authenticateWithLiveID($organizationServiceURL、$liveIDUseranme、$liveIDPassword);
if($securityData!=null&&isset($securityData)){
//echo(“\nKey标识符:”..securityData->getKeyIdentifier());
//echo(“\n安全令牌1:”.$securityData->getSecurityToken0());
//echo(“\n安全令牌2:”.$securityData->getSecurityToken1());
}否则{
echo“无法验证LiveId。”;
回来
}
回音“\n”;
$domainname=substr($CRMURL,8,-1);
$pos=strpos($domainname,“/”);
$domainname=substr($domainname,0,$pos);
打印(数据);
$contactRequest=EntityUtils::getCreateCRMSoapHeader($CRMURL,$securityData)。
名字
'.$data['Account']['name'].'
父客户ID
“.$data['Account']['id']”
00000000-0000-0000-0000-000000000000
联系
$response=LiveIDManager::GetSOAPResponse(“/Organization.svc”,$domainname、$CRMURL、$accountsRequest);
回音$应答;
$createResult=“”;
如果($response!=null&&$response!=“”){
preg_match(“/(.*)/”,$response,$matches);
$createResult=$matches[1];
}
有没有人经历过这一切和/或知道我错过了什么

谢谢,
Brad

必须将值的类型更改为ENITYREFERENCE等;下面是我的SOAP的更新主体。

名字
'.$data['Account']['name'].'
父客户ID
“.$data['Account']['category']”
账户

很抱歉格式化