nusoap 中的重复标签
我正在使用 nusoap 连接到肥皂网络服务。 该类发送到服务的 xml 是从数组构造的,即:
$params = array("param1" => "value1", "param2" => "value1");
$client->call('HelloWorld', $params, 'namespace', 'SOAPAction');
这工作正常。 多维数组还可以构造一个很好的嵌套 xml 消息。
当我需要两个同名的标签时遇到问题:
<items>
<item>value 1</item>
<item>value 2</item>
</item>
$params = array("items" => array("item" => "value 1", "item" => "value 2"));
数组中的第二项覆盖第一项,这会导致:
<items>
<item>value 2</item>
</item>
如何实现这一点?
I'm using nusoap to connect to a soap webservice. The xml that the class sends to the service is constructed from an array, ie:
$params = array("param1" => "value1", "param2" => "value1");
$client->call('HelloWorld', $params, 'namespace', 'SOAPAction');
This works fine. A multidimensional array also constructs a nice nested xml message.
I encounter a problem when i need two tags with the same name:
<items>
<item>value 1</item>
<item>value 2</item>
</item>
$params = array("items" => array("item" => "value 1", "item" => "value 2"));
The second item in the array overwrites the first which results in:
<items>
<item>value 2</item>
</item>
How can achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
问题在于内部 array()
创建一个具有单个键(“item”)的数组。
尝试一下,看看它是否有效:
不过,不能保证...我已经很长时间没有使用过 nusoap,并且这里没有安装 PHP 来测试它。
The problem is with the inner array()
creates an array with a single key ("item").
Try this and see if it works:
No guarantees, though... I haven't used nusoap in a long time and don't have PHP installed here to test it.
这很奇怪,因为 method:
对我有效。 正如所解释的
在此链接
也许您需要更新版本的 nusoap ?
This is strange because, method:
works form me. As explained
in this link
Maybe you need newer version of nusoap?
我们通过将字符串而不是数组传递给 nusoap 调用函数解决了这个问题。
请检查下面的链接
http://fundaa.com/php/solved-duplicate-tags-in-努肥皂/
we have solved this problem by passing string instead of array to nusoap call function.
please check link below
http://fundaa.com/php/solved-duplicate-tags-in-nusoap/
你的核心问题是你正在编写无效的 PHP 代码
Which of course won't work,因为它的同义词是
which of course won't work。
你最好的选择是使用
并希望数字键能够“工作”
或者
万一有这样的倾向。
此外
Looking through the examples on sourceforge, it would appear this is valid syntax:
http://nusoap.cvs.sourceforge.net/ viewvc/checkout/nusoap/samples/wsdlclient3b.php
这个显示使用非键控(即:数字)数组作为输入源:
http://nusoap.cvs.sourceforge.net/ viewvc/结帐/nusoap/samples/wsdlclient4.php
Your core problem is you're writing invalid PHP code
Which of course wont work, as its synonymous with
which of course won't work.
Your best bets are with
and hoping the numeric keys will "work"
or
in the event it is so inclined.
Additionally
Looking through the examples on sourceforge, it would appear this is valid syntax:
http://nusoap.cvs.sourceforge.net/viewvc/checkout/nusoap/samples/wsdlclient3b.php
This one shows using an un-keyed ( ie: numeric ) array as an input source:
http://nusoap.cvs.sourceforge.net/viewvc/checkout/nusoap/samples/wsdlclient4.php