在 PHP Soap 调用中重复数组中的元素
我正在进行肥皂调用,但其中一个嵌套元素会重复,因此当我创建数组时,它会被覆盖,对肥皂请求的元素进行编号。
$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'
)
)));
I'm making a soap call, but one of the nested elements repeats so it gets overwritten when I create the array, numbering the elements breaks to soap request.
$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'
)
)));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,在我的朋友的帮助下(以及 将 PHP 数组传递给SOAP 调用)我得到了解决方案。主要问题是 php 在第二次出现时覆盖了 attendee 变量。我必须找到一种方法来存储与会者的两个元素。我想我会在这里为后代发帖,因为它与其他问题略有不同。
So with a bit of help from my friends (and Passing a PHP array in a SOAP call) I got the solution. The primary problem was that php was overwriting the attendee variable with the second occurrence. I had to find a way to get both elements of attendee stored. Thought I would post here for posterity as it was slightly different than other problems.
如果您不明确地对重复的项目进行编号,会发生什么情况?
我想你应该看看这个类似的问题:PHP在肥皂中重复元素致电
What happens if you don't explicitely number repeated items, like that ?
I guess you should have a look at this similar question : PHP repeated elements in a soap call