-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_test.php
More file actions
66 lines (53 loc) · 1.88 KB
/
simple_test.php
File metadata and controls
66 lines (53 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
error_reporting(E_ALL);
ini_set('display_errors', '1');
echo "Simple SOAP Test\n";
echo "================\n\n";
$config = require __DIR__ . '/config/config.php';
echo "Testing connection to: " . $config['soap_uri'] . "\n";
echo "SSL Verification: " . ($config['verify_ssl'] ? 'enabled' : 'disabled') . "\n\n";
try {
$soapOptions = [
'location' => $config['soap_location'],
'uri' => $config['soap_uri'],
'trace' => true,
'exceptions' => true,
'connection_timeout' => 10,
];
if (!$config['verify_ssl']) {
echo "Disabling SSL verification...\n";
$soapOptions['stream_context'] = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
}
echo "Creating SOAP client...\n";
$client = new SoapClient(null, $soapOptions);
echo "SOAP client created successfully!\n\n";
echo "Attempting login...\n";
$sessionId = $client->login($config['username'], $config['password']);
if ($sessionId) {
echo "✓ Login successful!\n";
echo "Session ID: " . $sessionId . "\n";
// Try to get websites
echo "\nGetting websites...\n";
$websites = $client->sites_web_domain_get($sessionId, []);
echo "✓ Found " . count($websites) . " websites\n";
// Logout
$client->logout($sessionId);
echo "✓ Logged out\n";
} else {
echo "✗ Login failed - empty session ID\n";
}
} catch (SoapFault $e) {
echo "✗ SOAP Error: " . $e->getMessage() . "\n";
echo "Fault code: " . $e->faultcode . "\n";
echo "Fault string: " . $e->faultstring . "\n";
} catch (Exception $e) {
echo "✗ Error: " . $e->getMessage() . "\n";
}
echo "\nTest completed.\n";