V
V
Vyacheslav2015-02-06 07:44:08
PHP
Vyacheslav, 2015-02-06 07:44:08

SOAP request in PHP how to access attributes?

Hello. Please help me with the request.
I make a request to one service through the standard PHP SoapClient (which I can’t say, unfortunately), the problem is this:
the API requires, let’s say, to send an XML of the form:

<?xml version="1.0" encoding="utf-8"?>
<soap:Header>
...
</soap:Header>
<soap:Body>
    <QT_Param>
        <My_Param>какой то текст</My_Param >
    </QT_Param>
</soap:Body>

In PHP, the request code looks like this:
$client = new SoapClient($url, array('trace' => 1, 'exception' => 1, 'soap_version' => SOAP_1_1));
$ws_request['My_Param'] ='какой то текст';
$r = $client->ping($ws_request);

The problem is that everything I pass to $ws_request is automatically built between
<soap:Body>
    <QT_Param>

    </QT_Param>
</soap:Body>

and I need to get access to QT_Param to add the necessary attribute there, for example Who faced? How can these attributes be accessed? PS How to add attributes to xml I know the problem is that I don't know how to get to QT_Param <QT_Param myToken="1234">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krypt3r, 2015-02-06
@krypt3r

Have you already looked at SoapParam and SoapVar?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question