Using SOAP to generate XML attributes in PHP

妖精的绣舞 提交于 2019-12-30 10:05:00

问题


I found you can generate this in SOAP in php:

<foo bar="blah">12345</foo>

With this:

array("foo" => array("_" => 12345, "bar" => "blah"));

However, the underscore method does not seem to work when the value is not a number and string, but instead embedded xml code. How would you do this for instance?

<foo bar="blah">
    <aaa a="b">blah</aaa>
</foo>

This is an extension of this person's question: http://www.bigresource.com/Tracker/Track-php-uQwDoUib/


回答1:


I don't have a quick way of testing, but maybe this would work:

$a = array(
    'foo' => array(
        'bar' => 'blah',
        'aaa' => array(
            '_' => 'blah',
            'a' => "b",
        ),
    ),  
);



回答2:


How can you add an attribute to a node that is the function;

$update = $soap->UpdateMember($pRecord);

or

$update = $soap->__soapCall('UpdateMember', array($Updates));

I need to add namescape or xmlns attribute to the actual function name here. I'm getting the following;

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.sample.net/">
<SOAP-ENV:Body>
<ns1:UpdateMember>
MORE XML HERE
</ns1:UpdateMember>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

but I need

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.sample.net/">
<SOAP-ENV:Body>
<ns1:UpdateMember xmlns="http://www.sample.net/">
MORE XML HERE
</ns1:UpdateMember>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Need to have ns1:UpdateMember xmlns:ns1="http://www.sample.net/" or something like that.



来源:https://stackoverflow.com/questions/2045850/using-soap-to-generate-xml-attributes-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!