简体   繁体   English

如何创建此SOAP XML请求?

[英]How to create this SOAP XML request?

we are using SAOP clients for a while now without a problem. 我们使用SAOP客户端已有一段时间了,没有问题。 But now we are facing the following challenge and I can't find the answer. 但现在我们面临以下挑战,我找不到答案。 We need to send the following XML structure: 我们需要发送以下XML结构:

<Cards>
 <CardDetails>
  <Name>string</Name>
  <Address>string</String>
 </CardDetails>
 <CardDetails>
  <Name>string</Name>
  <Address>string</String>
 </CardDetails>
</Cards>

As you van see we need two instances of 'CardDetails'. 如您所见,我们需要两个“ CardDetails”实例。 Creating a PHP array will only allow me to send 1. 创建一个PHP数组只会允许我发送1。

$data = array(
    'Cards' => array(
        'CardDetails' => array(
            'Name' => 'test name',
            'Address' => 'test address'
        ),
        'CardDetails' => array(
            'Name' => 'second test name',
            'Address' => 'second test address'
        )
    )
));

Of course, only the second address will be used. 当然,将仅使用第二个地址。 But what would be the solution to make this work? 但是,使这项工作可行的解决方案是什么?

Thanks a lot! 非常感谢!

使用php dom从数组创建xml,这是一个很好的例子http://www.ibm.com/developerworks/library/os-xmldomphp/

And what function/class are you using to turn array to xml? 您正在使用什么函数/类将数组转换为xml?

Try this structure: 试试这个结构:

$data = array(
    'Cards' => array(
        'CardDetails' => array(
            array(
                'Name' => 'test name',
                'Address' => 'test address'
            ),
            array(
                'Name' => 'second test name',
                'Address' => 'second test address'
            )
        )
    )
);

If this doesn't work and you can modify serializing function, just check if current key is numerical. 如果这不起作用,您可以修改序列化功能,只需检查当前键是否为数字即可。 If it is, use parent key name for tag. 如果是这样,请使用父键名称作为标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM