PHP SoapClient丢弃字段?

时间:2013-12-31 21:18:06

标签: php soap salesforce

我正在使用php soap客户端功能来调用对Salesforce的调用...并且遇到了一些奇怪的事情,我无法弄明白。似乎一个字段在PHP调用中被删除...我可以在getLastReponse中看到它,但它不会从query()调用传递到对象中。我认为这不是Salesforce或wsdl的问题。

传递给Salesforce的查询:

$xml_array_query[‘query’]=“select Id, LastName, FirstName, Username, LMS_ID__c,
UserRole.Name, Name from User where IsActive=true and Name like '%Bunting%'”;

调用客户端(假设已经过身份验证确定)

$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions, 'location' => $serverurl));
$header = new SoapHeader('urn:enterprise.soap.sforce.com', 'SessionHeader', array ('sessionId'=>$sessionid));
$client->__setSoapHeaders($header);
$response = $client->query($xml_array_query['query']);

然后输出最后一个响应(格式化XML以供查看):

echo 'Last response: '. $client->__getLastResponse()."\n";

Last response: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
<soapenv:Header>
<LimitInfoHeader>
<limitInfo>
    <current>43227</current>
    <limit>895000</limit>
    <type>API REQUESTS</type>
</limitInfo>
</LimitInfoHeader>
</soapenv:Header>
<soapenv:Body>
<queryResponse>
<result> 
<done>true</done>
<queryLocator xsi:nil="true"/>
<records xsi:type="sf:User">
  <sf:Id>005d0x</sf:Id>
  <sf:FirstName>Susie</sf:FirstName>
  <sf:LMS_ID__c>BuntingSusieCC</sf:LMS_ID__c>    <------- KEY FIELD!
  <sf:LastName>Bunting</sf:LastName>
  <sf:Name>Susie Bunting</sf:Name>
  <sf:UserRole xsi:type="sf:UserRole">
     <sf:Id xsi:nil="true"/>
     <sf:Name>Agent Role</sf:Name>
  </sf:UserRole>
  <sf:Username>susie.bunting</sf:Username>
</records>
<size>1</size>
</result>
</queryResponse>
</soapenv:Body>
</soapenv:Envelope>

所以,我知道查询从服务器返回了LMS_ID__c字段......

但它看起来并不像字段和值传递到对象......

var_dump($response);

object(stdClass)#6 (1) {
  ["result"]=>
  object(stdClass)#7 (4) {
    ["done"]=>
    bool(true)
    ["queryLocator"]=>
    NULL
    ["records"]=>
    array(2) {
      [0]=>
       object(stdClass)#8 (6) {
        ["Id"]=>
        string(18) "005d0x"
        ["FirstName"]=>
        string(6) "Susie"
        ["LastName"]=>
        string(7) "Bunting"
        ["Name"]=>
        string(14) "Susie Bunting"
        ["UserRole"]=>
         object(stdClass)#9 (2) {
          ["Id"]=>
          NULL
          ["Name"]=>
          string(18) "Agent Role"
        }
        ["Username"]=>
        string(27) "susie.bunting"
      }
    }
    ["size"]=>
    int(1)
  }
}

LMS_ID_c字段在哪里?它在getLastReponse输出中,但是当从查询()查看对象时,它不存在。

我的理解是soapclient会解析XML来创建对象和元素,这是不是真的?
这是一些怪癖,因为字段名称中的下划线和双下划线的实例?我不这么认为,但我无法理解这一点。

任何帮助表示赞赏...

1 个答案:

答案 0 :(得分:3)

事实证明问题在于显然是对wsdl文件的缓存。我将此添加到我的脚本的头部,并解决了问题:

ini_set('soap.wsdl_cache_enabled',0);