request#

SOAP request and response.

class acore_soap.request.Base[source]#

Base class for SOAPRequest and SOAPResponse.

classmethod from_dict(dct: dict)[source]#

Construct an object from a dict.

to_dict() dict[source]#

Convert the object to a dict.

classmethod from_json(json_str: str)[source]#

Construct an object from a JSON string.

to_json() str[source]#

Convert the object to a JSON string.

class acore_soap.request.SOAPRequest(command: str, username: str = 'admin', password: str = 'admin', host: str = 'localhost', port: int = 7878)[source]#

SOAPRequest is a dataclass to represent the SOAP XML request.

Usage example

# this code only works in where the worldserver is running
>>> request = SOAPRequest(command=".server info")
>>> response = request.send()
>>> response.to_json()
{
    "body": "<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:ns1="urn:AC"><SOAP-ENV:Body><ns1:executeCommandResponse><result>AzerothCore rev. 85311fa55983 2023-03-25 22:36:05 +0000 (master branch) (Unix, RelWithDebInfo, Static)&#xD;Connected players: 0. Characters in world: 0.&#xD;Connection peak: 0.&#xD;Server uptime: 54 minute(s) 3 second(s)&#xD;Update time diff: 10ms, average: 10ms.&#xD;</result></ns1:executeCommandResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>",
    "message": "AzerothCore rev. 85311fa55983 2023-03-25 22:36:05 +0000 (master branch) (Unix, RelWithDebInfo, Static)Connected players: 0. Characters in world: 0.Connection peak: 0.Server uptime: 54 minute(s) 3 second(s)Update time diff: 10ms, average: 10ms.",
    "succeeded": true
}
Parameters:
  • command – the command to execute.

  • username – the in game GM account username, default “admin”.

  • password – the in game GM account password, default “admin”.

  • host – wow world server host, default “localhost”.

  • port – wow world server SOAP port, default 7878.

More methods from base class:

property endpoint: str#

Construct the Soap service endpoint URL.

send() SOAPResponse[source]#

Run soap command via HTTP request. This function “has to” be run on the game server and talk to the localhost. You should NEVER open SOAP port to public!

class acore_soap.request.SOAPResponse(body: str, message: str, succeeded: bool)[source]#

SOAPResponse is a dataclass to represent the SOAP XML response.

Usage:

>>> res = SOAPResponse.parse(
...  '''
...      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
...      ...<result>Account created: test&#xD;</result>...</SOAP-ENV:Envelope>
...  '''
... )
>>> res.message
Account created: test
>>> res.succeeded
True
Parameters:
  • body – the raw SOAP XML response

  • message – if succeeded, it is the <result>...</result> part. if failed, it is the <faultstring>...</faultstring> part

  • succeeded – a boolean flag to indicate whether the command is succeeded

More methods from base class:

classmethod parse(body: str) SOAPResponse[source]#

Parse the SOAP XML response.

print()[source]#

Print the dataclass, ignore the raw response body.

acore_soap.request.ensure_response_succeeded(request: SOAPRequest, response: SOAPResponse, raises: bool)[source]#

Ensure the response succeeded, otherwise raise an exception.