Php Soap Headers Not Getting Set - php

I can not get my php to set a value in the SOAP Header.
my code is
$requestParams = 'Parameters I am passing into the WS'
$client = new SoapClient('https://webservice.wsdl',array(
'login' => "user",
'password' => "password",
'trace' => 1,
'sessionID' => "93b23bb6e611db8548f2ee9485bc7d17"));
$client->submitRequest($requestParams);
process returned code and it does return what I expect
then
$client->release();
which should release this sessionID
The Web service I am calling uses a sessionID variable and if one is not passed it will create one for you but you can only have 5 unique sessions created before it locks you out for 5 min.
If you open a session you can reuse it as long as you free a session off and don't have more than five open.
My problem is that everything works but the web service does not see my sessionID variable because every time I make a call it issues me a new sessionID. So it created 5 new sessionID's and I have no way of freeing them off when completed and I have to wait till they timeout on the server.
Web Service Call #1 string(414) "HTTP/1.1 200 OK Date: Fri, 01 Aug
2014 20:56:32 GMT Server: Apache Set-Cookie:
PHPSESSID=ee6d8e3f9e6e1b9dac35e10f917a69c8; path=/ Expires: Thu, 19
Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache,
must-revalidate, post-check=0, pre-check=0 Pragma: no-cache
Set-Cookie: PHPSESSID=ee6d8e3f9e6e1b9dac35e10f917a69c8; path=/
Content-Length: 560 Connection: close Content-Type: text/xml;
charset=utf-8 "
Web Service Call #2 string(414) "HTTP/1.1 200 OK Date: Fri, 01 Aug
2014 20:57:18 GMT Server: Apache Set-Cookie:
PHPSESSID=46d99f3b92d095981119b7050686967c; path=/ Expires: Thu, 19
Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache,
must-revalidate, post-check=0, pre-check=0 Pragma: no-cache
Set-Cookie: PHPSESSID=46d99f3b92d095981119b7050686967c; path=/
Content-Length: 560 Connection: close Content-Type: text/xml;
charset=utf-8 "
And So on Till I get
A connection refused and I have to wait. If the session ID was passed in the SOAP HEADER from the code above the response would look like.
string(414) "HTTP/1.1 200 OK Date: Fri, 01 Aug 2014 20:58:18 GMT
Server: Apache Set-Cookie: PHPSESSID=93b23bb6e611db8548f2ee9485bc7d17;
path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store,
no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache
Set-Cookie: PHPSESSID=93b23bb6e611db8548f2ee9485bc7d17; path=/
Content-Length: 560 Connection: close Content-Type: text/xml;
charset=utf-8 "

You need to use the _cookies and the __setCookie methods on the SoapClient class to get and set the Session ID for use during SOAP calls.
Your code would look like this:
$requestParams = 'Parameters I am passing into the WS'
$sessionId = "93b23bb6e611db8548f2ee9485bc7d17";
$client = new SoapClient('https://webservice.wsdl',array(
'login' => "user",
'password' => "password",
'trace' => 1));
$client->__setCookie('PHPSESSID', $sessionId);
// ... your requests
If you are making the calls in separate stateless runs of the script, then you also would need to setup some method of persistence to make the Session ID persist between uses.

Related

Network Failure while download Using PHP Script

I am getting network failure message in chrome but working on other browser using php download script.
I have below headers set to download.
cache-control: must-revalidate, post-check=0, pre-check=0
content-disposition: attachment; filename="export.csv"
content-length: 388436
content-type: application/octet-stream
date: Thu, 19 Jul 2018 13:41:02 GMT
expires: Wed, 19 Jul 2017 13:40:59 GMT
last-modified: Thu, 19 Jul 2018 13:41:02 GMT
pragma: public
server: nginx
set-cookie: admin=p5t1vd4e4u3j9g6gto5h046ki0; path=/admin; domain=xyz.com; secure; HttpOnly
status: 200
x-powered-by: PHP/7.0.29
I am getting error in chrome version 67.3396.99

.Net HttpResponseMessage receiving BadGateway when take more than 1min

I have a windows service .Net client comunicating with a PHP web service. The basic idea, the .Net client send information to php to write in data base, this process take araund 1min, the problem is that, when it takes more, the HttpResponseMessage comes with BadGateway, the funny thing is php actually write all that has to write in the database even when it takes more than 1min. I try to set the TimeOut of HttpClient to 10min:
//code for the stuff making
Logger.WriteLog("Sending Stuff");
using (var client = new HttpClient())
{
client.Timeout = new TimeSpan(0,10,0);
httpResponseMessage = client.PostAsync(url, content).Result;
Logger.WriteLog(httpResponseMessage.StatusCode.ToString());
Logger.WriteLog(httpResponseMessage.ToString());
}
But still, it fail with more than 1min response, the php web service it suppose to have a timeout of 10min too. I log the full response and i got the bad Gateway:
2016-04-25 11:12:24,045 INFO - *Sending Stuff
2016-04-25 11:13:23,413 INFO - OK
2016-04-25 11:13:23,414 INFO - StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Pragma: no-cache
Connection: close
Cache-Control: no-store, must-revalidate, no-cache, post-check=0, pre-check=0
Date: Mon, 25 Apr 2016 14:12:37 GMT
Set-Cookie: PHPSESSID=lbhsue3pstc8smqihkoe0nouj1; path=/
Server: Apache/2.2.15
Server: (CentOS)
X-Powered-By: PHP/5.6.19
Content-Length: 52
Content-Type: application/json; charset=UTF8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
2016-04-25 11:14:42,931 INFO - *Sending Stuff
2016-04-25 11:15:44,273 INFO - BadGateway
2016-04-25 11:15:44,274 INFO - StatusCode: 502, ReasonPhrase: 'Proxy Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: close
Date: Mon, 25 Apr 2016 14:14:43 GMT
Content-Length: 499
Content-Type: text/html; charset=iso-8859-1
}
//------------------------------------------------------------------------------------------------------------------------------------------------
2016-04-25 11:25:28,471 INFO - *Sending Stuff
2016-04-25 11:26:27,495 INFO - OK
2016-04-25 11:26:27,497 INFO - StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Pragma: no-cache
Connection: close
Cache-Control: no-store, must-revalidate, no-cache, post-check=0, pre-check=0
Date: Mon, 25 Apr 2016 14:25:41 GMT
Set-Cookie: PHPSESSID=ja6f30mqlnhtdl8p44hddr43c3; path=/
Server: Apache/2.2.15
Server: (CentOS)
X-Powered-By: PHP/5.6.19
Content-Length: 52
Content-Type: application/json; charset=UTF8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
}
My hope was that, timeout where the reason of the badgateway but it make not difference. Can someone tell me what are the possibilities of the badgateway, even when the process in php finish the task. Thanks in advance!
PD:Sorry for my english
A timeout on the .NET end shouldn't generate an HTTP status code. It should throw a separate timeout exception. If you see an HTTP status code, that has to come from the server side.
Are you sure the web server itself (on the PHP end) isn't configured with a timeout for scripts?

Magento does not set cookie on product/category page

So here is the issue, Magento doesn't seem to set-cookie on product/category page.
It doesn't show any cart items or customer login information on product page, however all the items appear fine on home page and rest of the pages on site.
I checked headers for two of the pages.
Here is the product page:
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Tue, 15 Mar 2016 05:01:57 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Vary: Accept-Encoding
X-Cacheable: NO:Cache-Control=no-cache
Accept-Ranges: bytes
X-Served-From-Cache: Yes
Here is the home page headers (which is working fine)
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Tue, 15 Mar 2016 05:02:12 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: frontend=n7m2mbnoo861h84r9ma40of221; expires=Wed, 16-Mar-2016 05:02:12 GMT; path=/store/; domain=-----; HttpOnly
Vary: Accept-Encoding
X-Cacheable: NO:Cache-Control=no-cache
Accept-Ranges: bytes
X-Served-From-Cache: Yes
Any idea what's happening?
I have tried increasing cookie lifetime to 86400
and cookie path to /store/ and cookie domain to (www.mydomain.com)
It turns out issue was misconfiguration of varnish on server. It was serving cached pages. Solution: Restarted varnish.

Readfile image not working on PHP

I have the below PHP code to load image
header('Content-Type: image/'.$contentFormat);
header('Content-Length: '. filesize($image));
readfile($image);
When I request the url in console I get the bellow header response
HTTP/1.1 200 OK
Date: Fri, 28 Nov 2014 13:13:59 GMT
Content-Type: image/jpeg
Content-Length: 107885
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Powered-By: PHP/5.3.13
Set-Cookie: PHPSESSID=617a3a6eba912178f810f10cc5d171f3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Accept-Ranges: bytes
Age: 0
ÿØÿà
including ÿØÿà,
What could be the problem? I searched all my php files for whitespace. Any guess or suggestions where I can search for the whitespace

multiple PHPSESSID cookies and browser doesn't keep any

I'm getting 2 PHPSESSID set cookies headers from a login request from my yii application.
Date: Thu, 05 Dec 2013 02:19:44 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3
Set-Cookie: PHPSESSID=3lkhjlsv967n56horpcl3n7gl5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=sctb6cd1snbd5g2esv1mn2lug7; path=/
Content-Length: 3
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
And browser doesn't keep any and doesn't send back them for future requests. Any idea how this is happening?

Categories