2011-12-09 33 views
1

我有一個數據要發送到SOAP客戶端的數組。 這一切都有效,但不會傳輸一條數據,如__getLastRequest()所示。發送到客戶端時PHP和SOAP數據丟失

這裏是我的代碼

<?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" => "[email protected]" 
    ), 
     "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"; 

的零售[0] [ 'dealerCode']是信息的唯一一塊從發送XML省略。

任何想法?

非常感謝。

+0

想法?現在只有一個......如何以清晰的方式格式化您的代碼? ;)認真地說:一個問題並沒有顯示出格式化的重要性,而不像OP顯示他/她所關心的問題那樣可能會得到答案/ upvotes! :) – mac

+0

如果你給我買一個更大的屏幕,我將能夠閱讀你的代碼;)。 – middus

回答

2

正如mac所說,格式化代碼會很好,但我注意到的一件事是「零售商」字段是唯一一個大寫。不確定WSDL是否對客戶端發送的內容有任何影響,但可能會發生。

仔細檢查WSDL,看看該字段是否應該是「零售商」。任何你可以共享WSDL的機會,順便說一句?

編輯 審查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> 
+0

php soap客戶端確實忽略了在WSDL中沒有定義字段的數據。這個答案應該引導你! –

+0

@quickshiftin,將Ratailer更改爲'retailer'導致錯誤:「找不到dealerCode」。這裏是鏈接到WSDL [鏈接](http://www.autorotation.org/tmp/test.wsdl) 感謝您的幫助和對格式化cock-up – Shmoyko