How can I run a command after enabling SOAP to AzerothCore worldserver console?
Advertisement
Answer
First of all, you have to put on worldserver.conf these parameters to enable SOAP:
SOAP.Enabled = 1 SOAP.IP = "127.0.0.1" SOAP.Port = 7878
Afterwards, run your worldserver.
You can use a simple PHP script to run a command to the AzerothCore console like the following,
If you don’t have php-soap, on Linux Ubuntu you can install it using sudo apt install php-soap (or php7.2-soap).
<?php
$soap_connection_info = array(
'soap_uri' => 'urn:AC',
'soap_host' => '127.0.0.1',
'soap_port' => '7878',
'account_name' => 'USERNAME',
'account_password' => 'PASSWORD'
);
function RemoteCommandWithSOAP($username, $password, $COMMAND)
{
global $soap_connection_info;
$result = '';
try {
$conn = new SoapClient(NULL, array(
'location' => 'http://' . $soap_connection_info['soap_host'] . ':' . $soap_connection_info['soap_port'] . '/',
'uri' => $soap_connection_info['soap_uri'],
'style' => SOAP_RPC,
'login' => $username,
'password' => $password
));
$result = $conn->executeCommand(new SoapParam($COMMAND, 'command'));
unset($conn);
} catch (Exception $e) {
$result = "Have error on soap!n";
if (strpos($e, 'There is no such command') !== false) {
$result = 'There is no such command!';
}
}
return $result;
}
echo RemoteCommandWithSOAP($soap_connection_info['account_name'], $soap_connection_info['account_password'], ".server info");
?>
In the last line you have to change "account_name", "account_password" using an account with gm level 3.
echo RemoteCommandWithSOAP($soap_connection_info['account_name'], $soap_connection_info['account_password'], ".server info");
You can replace .server info with any command.
Note: this works with other emulators just replacing urn:AC with:
– urn:MaNGOS for CMaNGOS (and related forks)
– urn:TC for TrinityCore
– urn:SF for SkyfireProject
– urn:Oregon for OregonCore
etc…