Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 7 support #34

Open
JanaFischinger opened this issue May 25, 2020 · 4 comments
Open

version 7 support #34

JanaFischinger opened this issue May 25, 2020 · 4 comments

Comments

@JanaFischinger
Copy link

any news about support for version 7?

@sermoshkin
Copy link

any news about support for version 7?

Hi, on version 7 everything works because the vmware_soap_session Cookie is not thrown at one moment.
It is enough to edit the __doRequest method in the SoapClient.php file:

` function __doRequest($request, $location, $action, $version, $one_way = 0) {
$request = $this->appendXsiTypeForExtendedDatastructures($request);

	$headers = parent::__getLastResponseHeaders();
	$arHeaders = explode(PHP_EOL, $headers);
	foreach ($arHeaders as $value)
	{
		$val = explode(':', $value);
		$arHeaders[ strtolower($val[0]) ] = ($val[1]) ? trim($val[1]) : '';
	}
	
	if (!empty($arHeaders['set-cookie']))
	{
		$re = '/(.+)="(.+)";/m';
		preg_match_all($re, $arHeaders['set-cookie'], $matches, PREG_SET_ORDER, 0);
		parent::__setCookie('vmware_soap_session', '"'.$matches[0][2].'"');
	}
	
	$result = parent::__doRequest($request, $location, $action, $version, $one_way);
	
	if (isset($this->__soap_fault) && $this->__soap_fault) {
		throw $this->__soap_fault;
	}
	return $result;
}`

@dlepenven
Copy link

@sermoshkin You are my saviour :-D

It works for me and it is compatible with VCenter 6 too.

I just changed

  • $arHeaders[ strtolower($val[0]) ] = ($val[1]) ? trim($val[1]) : '';

To

  • $arHeaders[ strtolower($val[0]) ] = (isset($val[1])) ? trim($val[1]) : '';

To avoid warning

@rendragnet
Copy link

Incase anyone is scratching their heads trying to figure out why none of these help with version 7 support... Upgrade your PHP version. We just deployed the system that uses this library into docker swarm, and went from php 5.4 to 7.4 as part of that. and with no code changes, we now can use vcenter 7! Was a nice surprise, as digging in to find out exactly why we couldn't talk to our v7 vCenters, and fixing it, was my job for next week :D

@sermoshkin
Copy link

sermoshkin commented Feb 27, 2022

I didn't check on php 7.4) at least there are two ways to solve: changing the code from the comments above or trying to update the php version 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants