N
N
Nikita2015-12-08 11:38:16
PHP
Nikita, 2015-12-08 11:38:16

How can I set the WSS-PasswordType for a SOAP client?

Help, please, to deal with authorization for the SOAP client. How can I specify the WSS-PasswordType:PasswordText parameter for the client and pass it for authorization to the server.
What I tried:
1) I collect the correct structure in XML with my hands and add it as a header through SoapHeader

$header[] = new SoapHeader("http://schemas.xmlsoap.org/ws/2003/06/secext", 'Security', new \SoapVar($xml, XSD_ANYXML), 1);

As a result, the structure is correct; when testing through SoapUI, I get the correct answer. When running the script and calling the function - the response contains NULL
2) I tried to add headers using third-party libraries, like WsSecurity - the result is the same - I get NULL

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sivabur, 2015-12-09
@sivabur

$client = new SoapClient(' magentohost/api/soap/?wsdl ');
// If somestuff requires api authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'catalog_product.list');
var_dump($result);
// If you don't need the session anymore
// $client->endSession($session);
Something like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question