簡體   English   中英

帶有 PHP Soap 客戶端的多維數組

[英]Multidimensional Array with PHP Soap Client

我正在嘗試創建一個 SOAP 客戶端,但我需要按照文檔中的要求發送一個多維數組(我認為),示例如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.senior.com.br">
  <soapenv:Body>
    <ser:ColaboradoresAdmitidos>
      <user>String</user>
      <password>String</password>
      <encryption>Integer</encryption>
      <parameters>
        <NumEmp>Integer</NumEmp>
        <AbrTipCol>String</AbrTipCol>
        <IniPer>DateTime</IniPer>
        <FimPer>DateTime</FimPer>
      </parameters>
    </ser:ColaboradoresAdmitidos>
  </soapenv:Body>
</soapenv:Envelope>

我創建了一個這樣的數組:

$arguments = [
    'user' => 'xxxxx',
    'password' => 'xxxxxxxxxx',
    'encryption' => 0,
    'parameters' => array(
        'NumEmp' => 1, 
        'AbrTipCol' => '1', 
        'IniPer' => '01/01/2019', 
        'FimPer' => null
    ),
];

$client = new SoapClient($url, array('trace' => 1));
dd($arguments, $client->__soapCall("colaboradoresAdmitidos", $arguments), $client->__getLastRequest());

但是在請求中,好像不接受數組,其實我做了一些測試,除了前3個參數外,沒有進入生成的XML。

我已經以不同的方式制作了數組,並更改了參數值,但它始終返回如下:

<?xml version="1.0" encoding="UTF-8"?>\n
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://services.senior.com.br">
    <SOAP-ENV:Body> 
        <ns1:ColaboradoresAdmitidos>
            <user>xxxxxxx</user>
            <password>xxxxxxxxx</password>
            <encryption>0</encryption>
            <parameters/>
        </ns1:ColaboradoresAdmitidos>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

有人可以幫助我,因為服務器知道缺少參數,所以我無法執行查詢。

在網上搜索,我發現有很多人有這個問題,但他們無法解決。 我發現了錯誤。 當參數與 WSDL 中注冊的參數不匹配時,就會發生這種情況。 就我而言:文檔用大寫字母提到參數,但是,我不得不用小寫字母使用它。

似乎參數鍵必須與 wsdl 中注冊的值相同。 前任:

$arguments = [
'user' => 'xxxxx',
'password' => 'xxxxxxxxxx',
'encryption' => 0,
'parameters' => array(
    'numEmp' => 1, 
    'abrTipCol' => '1', 
    'iniPer' => '01/01/2019', 
    'fimPer' => null
)];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM