// Set up SoapClient $client = new SoapClient('http://example.com/soap?wsdl'); // Define login credentials $login = array( 'username' => 'myusername', 'password' => 'mypassword' ); // Call login method of SOAP server with credentials $result = $client->__soapCall('login', array($login)); // Print result print_r($result);
// Set up SoapClient $options = array( 'login' => 'myusername', 'password' => 'mypassword' ); $client = new SoapClient('http://example.com/soap?wsdl', $options); // Call login method of SOAP server $result = $client->login(); // Print result print_r($result);In the examples above, we are creating a SoapClient to communicate with a SOAP server. We define our login credentials as an array and pass it as a parameter to the `__soapCall` or `$client->login()` method. The library used for these examples is the built-in PHP SoapClient library. It can be included in PHP projects by default and is not part of any package library.