What are the key components of a SOAP request in PHP and how should they be formatted?

In order to make a SOAP request in PHP, you need to include key components such as the SOAP client, the SOAP endpoint URL, the SOAP action, and the SOAP request parameters. These components should be formatted correctly in order to successfully send a SOAP request and receive a response.

// Create a new SOAP client
$client = new SoapClient("http://example.com/soap.wsdl");

// Define the SOAP endpoint URL
$endpoint = "http://example.com/soap";

// Define the SOAP action
$action = "http://example.com/soapAction";

// Define the SOAP request parameters
$params = array('param1' => 'value1', 'param2' => 'value2');

// Make the SOAP request
$response = $client->__soapCall($action, $params, array('location' => $endpoint));

// Process the SOAP response
var_dump($response);