N
N
n0ip2012-06-22 16:27:54
PHP
n0ip, 2012-06-22 16:27:54

How to correctly add attributes to a SOAP request using SoapVar?

It is necessary to generate such XML by means through SoapClient. Remote wsdl service does not provide.

<sys:Test attr1="val1" attr2="val2" xmlns:sys="http://www.test.com/schema/system_v1">
            <sys:Val attr="val">blablabla</sys:Val>
</sys:Test>


How to correctly pass attributes to the $client->Test($params) function, where $params = new SoapVar('test', XSD_STRING) to get the XML code described above.

Found this on php.net:
$tag[]['_'] = 'yyy'; 
$tag[]['attr'] = 'xxx'; 
$tagVar = new SoapVar($tag, SOAP_ENC_OBJECT);


But instead of parameters, it generates a hierarchical xml tree and it's still not entirely clear how to add attributes to the function itself. I would like to find the most direct option without redefining everything and everyone (for example, the __doRequest method).

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
s0rr0w, 2012-06-23
@s0rr0w

Most likely, only with the help of low-level generation of an XML response using the DOM or SimpleXML, using the __doRequest method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question