2011-12-15 88 views
2

我正在做一個肥皂調用,但其中一個嵌套元素重複,所以它會被覆蓋,當我創建數組,編號的元素休息肥皂請求。重複數組中的元素爲一個PHP肥皂呼叫

$result = $client->SaveEventRegistration(array(

    'SetEventRegistrationRQ' => array(

     'Attendees' => array( 
      'Attendee' => array(
       'EventRegistrationTypeID' => '3125', 
       'NoofSeats' => '2', 
       'RegistrationCost' => '20', 
       'Contact' => array(
        'FirstName' => 'Danny', 
        'LastName' => 'Hulk', 
        'Email' => '[email protected]', 
        'IsForNewsletter' => 'true' 
        ) 
       ), 
       'Attendee' => array(
       'EventRegistrationTypeID' => '3149', 
       'NoofSeats' => '2', 
       'RegistrationCost' => '30', 
       'Contact' => array(
        'FirstName' => 'Penny', 
        'LastName' => 'Hulk', 
        'Email' => '[email protected]', 
        'IsForNewsletter' => 'true' 
        ) 
       ) 
      ), 
     'EventId' => '2652', 
     'RegistrationBy' => array(
      'FirstName' => 'Incredible', 
      'LastName' => 'Hulk', 
      'Email' => '[email protected]', 
      'EventScheduleId' => '2617' 
     ) 
     ))); 
+0

這些許多元素中哪些重複(和哪裏)? – hakre 2011-12-16 00:18:24

回答

0

如果你沒有明確地重複編號的話,會發生什麼?

$result = $client->SaveEventRegistration(array(

'SetEventRegistrationRQ' => array(

    'Attendees' => array( 

     array(
      'EventRegistrationTypeID' => '3125', 
      'NoofSeats' => '2', 
      'RegistrationCost' => '20', 
      'Contact' => array(
       'FirstName' => 'Danny', 
       'LastName' => 'Hulk', 
       'Email' => '[email protected]', 
       'IsForNewsletter' => 'true' 
       ) 
      ), 
     array(
      'EventRegistrationTypeID' => '3149', 
      'NoofSeats' => '2', 
      'RegistrationCost' => '30', 
      'Contact' => array(
       'FirstName' => 'Penny', 
       'LastName' => 'Hulk', 
       'Email' => '[email protected]', 
       'IsForNewsletter' => 'true' 
       ) 
      ) 
     ), 
    'EventId' => '2652', 
    'RegistrationBy' => array(
     'FirstName' => 'Incredible', 
     'LastName' => 'Hulk', 
     'Email' => '[email protected]', 
     'EventScheduleId' => '2617' 
    ) 
    ))); 

我想你應該看看這個類似的問題:PHP repeated elements in a soap call

2
有一點我的朋友(和 Passing a PHP array in a SOAP call)我得到的解決方案的幫助

左右。主要問題是php在第二次出現時覆蓋了與會者變量。我不得不找到一種方法讓參與者的兩個元素都存儲起來。以爲我會在這裏爲後人發帖,因爲它與其他問題略有不同。

// turn $attendee into an array (I think it's non-associative?) 
     $attendee = array(); 
    // create the elements that repeat. Note the name of the array becomes part of the soap call so must be the right parameter you intend to send in the SOAP call. 
     $attendee[] = array(
        'EventRegistrationTypeID' => '3125', 
        'NoofSeats' => '2', 
        'RegistrationCost' => '20', 
        'Contact' => array(
         'FirstName' => 'Danny', 
         'LastName' => 'Hulk', 
         'Email' => '[email protected]', 
         'IsForNewsletter' => 'true' 
         )); 
$attendee[] = array(
        'EventRegistrationTypeID' => '3149', 
        'NoofSeats' => '2', 
        'RegistrationCost' => '20', 
        'Contact' => array(
         'FirstName' => 'Penny', 
         'LastName' => 'Hulk', 
         'Email' => '[email protected]', 
         'IsForNewsletter' => 'true' 
         )); 


// make the SOAP call ($client defined elsewhere). Insert the array created above in the appropriate place inside the correct tag (Attendees in my case). 

$result = $client->SaveEventRegistration(array(

     'SetEventRegistrationRQ' => array(

      'Attendees' => $attendee, 
      'EventId' => '2652', 
      'RegistrationBy' => array(
       'FirstName' => 'Incredible', 
       'LastName' => 'Hulk', 
       'Email' => '[email protected]', 
       'EventScheduleId' => '2617' 
      ))));