2011-12-15 95 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' 
      ))));