T
T
tvolf2015-10-02 16:52:53
PHP
tvolf, 2015-10-02 16:52:53

How to access WSDL of Lotus Domino web service from PHP (SoapClient) when requesting cookie last?

Hello.
Faced such a problem. There is a Lotus Domino server by means of which the WSDL web service is lifted.
This web service uses login and password authorization. That is, roughly speaking, if I directly try to get the exampe.com/....?WSDL page with a GET request, then I first get to the example.com/names.nsf?Login authorization page, which prompts me to enter a password and login. If the password and login are correct, then by means of a 302 redirect, the normal content of the main page of the web service is given to me.
At the same time, if the username and password are entered correctly, a cookie of the form is set:
DomAuthSessId=XXXXXXXXXX The cookie
is set for the working session. This was the preamble.
Now to the problem itself.
To use this web service from PHP, I use (sorry for the tautology) SoapClient.
General usage mechanism:
$client = new SoapClient( ' example.com/....?WSDL ');
$client->funcName(...params...);
...
On the very first line, I get a SOAP exception about the incorrectness of the received ?WSDL page. It is understandable -
cookies are not transmitted in any way, and I do not receive WSDL information, but a form for entering a login and password.
Googled on the subject of passing cookies when working with SOAP. There is a $client->__setCookie() function that allows you to set them. But this requires at least a normally instantiated client (that is, the $client variable), and I don’t even create it normally...
I tried on my own before calling new SoapClient() to make a POST request to the URL from the authorization form and read the DomAuthSessId cookie. I get its value, but then what to do with it? After all, the first time new SoapClient() is called, another connection will be used, which will require a cookie with a different value ?
The situation is generally incomprehensible, because before the creation of SoapClient we cannot know the value of the cookie (it will be known only after we have passed authorization).
Tell me, please, how to be? Maybe someone faced something similar?
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rainbird, 2015-10-02
@tvolf

Why do you think that a cookie obtained from a post request will not work? Form a stream_context with this cookie and pass it when creating the SoapClient

$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Cookie: DomAuthSessId=XXXXXXXXXX\r\n"
  )
);
$context = stream_context_create($opts);
$client = new SoapClient('...', array('stream_context' => $context));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question