发送到客户端时PHP和SOAP数据丢失

时间:2011-12-09 16:35:31

标签: php xml soap data-loss

我想要发送到SOAP客户端的数据数组。 这一切都有效,但是__getLastRequest()揭示了一条数据没有传输。

这是我的代码

<?php

  $test_array = array(
    "request"   =>  array(
      "dateTime"          =>  "2011-12-05T11:37:06.0000000+00:00",
      "brandId"           =>  2,
      "extSysId"          =>  11,
      "extSysPassword"    =>  "xxxxx",
      "customer"          =>  array(
        "title" => "Mr",
        "firstName" =>  "Dec",
        "lastName" => "Test-Two",
        "address" => array(
          "type" => "Residential",
          "pafValidated" => TRUE,
          "houseNumber" => "xx",
          "houseName" => "",
          "line1" => "xx xx",
          "line2" => "",
          "line3" => "xx",
          "line4" => "",
          "line5" => "",
          "postcode" => "xxx xxx"
        ),
        "phones" => array(
          0 => array(
            "type" => "Home",
            "_" => "xxx xxxxxx"
          ),
          1 => array(
            "type" => "Work",
            "preferred" => TRUE,
            "_" => ""
          ),
          2 => array(
            "type" => "Mobile",
            "preferred" => TRUE,
            "_" => ""
          )
        ),
        "email" => "xxxx.xxxx@gmail.com"
      ),
      "nextPurchase"  => array(
        "date" => "2014-05-01"
      ),
      "dataProtection" => array(
        "group" => FALSE,
        "thirdParty" => FALSE
      ),
      "futureContactChannels" => array(
        0 => array(
          "type" => "Whitemail",
          "option" => FALSE
        ),
        1 => array(
          "type" => "Email",
          "option" => FALSE
        ),
        2 => array(
          "type" => "Phone",
          "option" => FALSE
        ),
        3 => array(
          "type" => "SMS",
          "option" => FALSE
        )
      ),
      "vehicleRequests" => array(
        0 => array(
          "derivativeCode" => "xxxxx",
          "type" => "T"
        )
      ),
      "Retailer" => array(
        0 => array (
          "dealerCode" => "00082"
        )
      ),
      "company" => array(
        "companyName" => "",
        "jobTitle" => ""
      ),
      "campaign" => array(
        "code" => "xxxxxxxxx",
        "source" => 69
      ),
      "notes" => "blah balh: ."
    )
  );

$client = new SoapClient("/xxx/xxxx/xxxxxx/xxxxx.wsdl", array(
  "login" => "xxx", 
  "password" => "xxx",
  "location" => "http://xxx.xxx.xxx.xxx/xxxxxx/Some.asmx",
  "uri" => "urn:xmethods-delayed-quotes",
  'trace' => 1,
  'exceptions' => 1,
  'soap_version' => 'SOAP_1_1',
  'encoding' => 'UTF-8',
  'features' => 'SOAP_USE_XSI_ARRAY_TYPE'
));


$client->CallComeFunction($test_array);

echo "REQUEST:\n" . $client->__getLastRequest() . "\n";

echo "*************************************************\n";

echo "Response:\n" . $client->__getLastResponse() . "\n";

Retailed [0] ['dealerCode']是发送的XML中唯一的信息。

有什么想法吗?

非常感谢。

1 个答案:

答案 0 :(得分:2)

正如mac所说,格式化代码会很好,但我注意到的一件事是'零售商'字段是唯一被大写的字段。不确定WSDL是否对客户端发送的内容有任何影响,但可能会。

仔细检查WSDL,看看该字段是否应该是'零售商'。你有没有机会分享WSDL,顺便说一下?

EDIT 在审查了WSDL之后,“零售商”是可行的方法:

<s:element minOccurs="0" maxOccurs="1" name="retailer" type="tns:Retailer"/>

有效负载的格式也应该不同,它应该是

"retailer" => array(
    "dealerCode" => "00082"
)

根据WSDL

<s:complexType name="Retailer">      
    <s:attribute name="dealerCode" type="s:string"/>        
</s:complexType>