PHP SoapClient字段缺少数据

时间:2015-08-25 20:32:54

标签: php xml soap

EDITED 祸了,我说,SoapClient让我失望了,让我的心脏和参数变黑了。使用此代码:

class WebServices
{
  /** @var $client \SoapClient */
  public $client;

  /**
   * @param $username
   * @param $password
   */
  function __construct($username, $password)
  {
    $wsdl = URL;
    $options = array(
      'login'    => $username,
      'password' => $password,
      'trace'    => true
    );
    $this->client = new \SoapClient($wsdl, $options);
  }


  function deleteFromContacts($crmDeleteSettings, $record){
    if ($crmDeleteSettings == null){
      $crmUs = new CRMDeleteSettings();
      $crmDeleteSettings = $crmUs->toArray($record);
    }

    $data = array(
      'crmDeleteSettings' => $crmDeleteSettings,
      'importData'        => array('values' => array_values($record))
    );

    $result = $this->client->deleteFromContacts($data);
    return $result;
  }
}

我有以下数组:

    Array
    (
        [crmDeleteSettings] => Array
            (
                [allowDataCleanup] => true
                [fieldsMapping] => Array
                    (
                        [0] => Array
                            (
                                [columnNumber] => 1
                                [fieldName] => number1
                                [key] => true
                            )

                    )

                [skipHeaderLine] => false
                [failFieldOnParseError] => true
                [crmDeleteMode] => DELETE_ALL
            )

        [importData] => Array
            (
                [values] => Array
                    (
                        [0] => XXXXXXXXXX
                    )

            )

    )

我通过肥皂发送它,使用SoapClient,失败,当我检查上次发送的请求时,这就是我发送的内容:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="XXXXXXX">
  <SOAP-ENV:Body>
    <ns1:deleteFromContacts>
      <crmDeleteSettings>
        <allowDataCleanup>true</allowDataCleanup>
        <fieldsMapping>
          <columnNumber>1</columnNumber>
          <fieldName>number1</fieldName>
          <key>true</key>
        </fieldsMapping>
        <skipHeaderLine>true</skipHeaderLine>
        <crmDeleteMode>DELETE_ALL</crmDeleteMode>
      </crmDeleteSettings>
      <importData>
        <values/>
      </importData>
    </ns1:deleteFromContacts>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

正如您所看到的,importData节点应该有一个包含我作为数组成员发送的值的子节点,但是它显示了一个空节点,我应该看到

<values>XXXXXXXXXX</values>

有没有人对我没看到的原因有任何想法?

0 个答案:

没有答案